From d7c367ae91ba8b4634053e6eff7f346a9a6d71cb Mon Sep 17 00:00:00 2001 From: barisusakli <barisusakli@gmail.com> Date: Tue, 18 Nov 2014 00:10:42 -0500 Subject: [PATCH] moved new notification to events.js --- public/src/client/topic.js | 9 +-------- public/src/client/topic/events.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/public/src/client/topic.js b/public/src/client/topic.js index 572f178868..edf5efcff5 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -76,9 +76,8 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT function setupSocketListeners() { socket.removeListener('event:new_post', onNewPost); - socket.removeListener('event:new_notification', onNewNotification); + socket.on('event:new_post', onNewPost); - socket.on('event:new_notification', onNewNotification); } Topic.toTop = function() { @@ -159,12 +158,6 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT createNewPosts(data); } - function onNewNotification(data) { - var tid = ajaxify.variables.get('topic_id'); - if (data && data.tid && parseInt(data.tid, 10) === parseInt(tid, 10)) { - socket.emit('topics.markTopicNotificationsRead', tid); - } - } function addBlockQuoteHandler() { $('#post-container').on('click', 'blockquote .toggle', function() { diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index 1318ae23df..d4883cdd53 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -40,6 +40,8 @@ define('forum/topic/events', ['forum/topic/browsing', 'forum/topic/postTools', ' 'posts.downvote': togglePostVote, 'posts.unvote': togglePostVote, + 'event:new_notification': onNewNotification, + 'event:topic.notifyTyping': onNotifyTyping, 'event:topic.stopNotifyTyping': onStopNotifyTyping }; @@ -184,6 +186,14 @@ define('forum/topic/events', ['forum/topic/browsing', 'forum/topic/postTools', ' post.find('.downvote').toggleClass('btn-primary downvoted', data.downvote); } + + function onNewNotification(data) { + var tid = ajaxify.variables.get('topic_id'); + if (data && data.tid && parseInt(data.tid, 10) === parseInt(tid, 10)) { + socket.emit('topics.markTopicNotificationsRead', tid); + } + } + function onNotifyTyping(data) { var userEl = $('.thread_active_users [data-uid="' + data.uid + '"]'); userEl.addClass('replying');