mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-21 07:50:37 +01:00
fix duplicate event listeners
they were duplicated if you navigated from topic to topic
This commit is contained in:
@@ -65,8 +65,7 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
|
|
||||||
navigator.init('.posts > .post-row', postCount, Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
|
navigator.init('.posts > .post-row', postCount, Topic.toTop, Topic.toBottom, Topic.navigatorCallback, Topic.calculateIndex);
|
||||||
|
|
||||||
socket.on('event:new_post', onNewPost);
|
setupSocketListeners();
|
||||||
socket.on('event:new_notification', onNewNotification);
|
|
||||||
|
|
||||||
$(window).on('scroll', updateTopicTitle);
|
$(window).on('scroll', updateTopicTitle);
|
||||||
|
|
||||||
@@ -75,6 +74,13 @@ define('forum/topic', dependencies, function(pagination, infinitescroll, threadT
|
|||||||
socket.emit('topics.enter', tid);
|
socket.emit('topics.enter', tid);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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() {
|
Topic.toTop = function() {
|
||||||
navigator.scrollTop(0);
|
navigator.scrollTop(0);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user