Skip to content

Node.js based forum software built for the modern web

moved new notification to events.js

barisusaklid7c367ae91ba
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');