diff --git a/public/src/forum/home.js b/public/src/forum/home.js index cc6bd63fdf..62d4b8298f 100644 --- a/public/src/forum/home.js +++ b/public/src/forum/home.js @@ -1,8 +1,24 @@ +'use strict'; + define(function() { var home = {}; home.init = function() { + app.enterRoom('home'); + + ajaxify.register_events([ + 'event:new_topic', + 'event:new_post' + ]); + + socket.on('event:new_topic', function(data) { + + }); + + socket.on('event:new_post', function(data) { + + }); } return home; diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 99103fb340..c359244154 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -70,9 +70,12 @@ SocketPosts.reply = function(socket, data, callback) { var socketData = { posts: [postData] }; - index.server.sockets.in('topic_' + postData.tid).emit('event:new_post', socketData); - index.server.sockets.in('recent_posts').emit('event:new_post', socketData); - index.server.sockets.in('user/' + postData.uid).emit('event:new_post', socketData); + + var rooms = ['recent_posts', 'home', 'topic_' + postData.tid, 'user/' + postData.uid]; + rooms.forEach(function(room) { + index.server.sockets.in(room).emit('event:new_post', socketData); + }); + callback(); } }); diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index f31084d943..6a3b4ea086 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -57,8 +57,10 @@ SocketTopics.post = function(socket, data, callback) { } if (result) { + index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData); index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData); + index.server.sockets.in('home').emit('event:new_topic', result.topicData); index.server.sockets.in('user/' + socket.uid).emit('event:new_post', { posts: result.postData });