mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-30 10:35:55 +01:00
fix: #7142
due to no refresh on login socket listeners were added more than once, so remove them before adding the listeners
This commit is contained in:
@@ -18,19 +18,28 @@ define('forum/header/chat', ['components'], function (components) {
|
|||||||
requireAndCall('loadChatsDropdown', chatsListEl);
|
requireAndCall('loadChatsDropdown', chatsListEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('event:chats.receive', function (data) {
|
socket.removeListener('event:chats.receive', onChatMessageReceived);
|
||||||
requireAndCall('onChatMessageReceived', data);
|
socket.on('event:chats.receive', onChatMessageReceived);
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('event:user_status_change', function (data) {
|
socket.removeListener('event:user_status_change', onUserStatusChange);
|
||||||
requireAndCall('onUserStatusChange', data);
|
socket.on('event:user_status_change', onUserStatusChange);
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('event:chats.roomRename', function (data) {
|
socket.removeListener('event:chats.roomRename', onRoomRename);
|
||||||
requireAndCall('onRoomRename', data);
|
socket.on('event:chats.roomRename', onRoomRename);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onChatMessageReceived(data) {
|
||||||
|
requireAndCall('onChatMessageReceived', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUserStatusChange(data) {
|
||||||
|
requireAndCall('onUserStatusChange', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRoomRename(data) {
|
||||||
|
requireAndCall('onRoomRename', data);
|
||||||
|
}
|
||||||
|
|
||||||
function requireAndCall(method, param) {
|
function requireAndCall(method, param) {
|
||||||
require(['chat'], function (chat) {
|
require(['chat'], function (chat) {
|
||||||
chat[method](param);
|
chat[method](param);
|
||||||
|
|||||||
@@ -21,15 +21,21 @@ define('forum/header/notifications', ['components'], function (components) {
|
|||||||
requireAndCall('loadNotifications', notifList);
|
requireAndCall('loadNotifications', notifList);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.on('event:new_notification', function (data) {
|
socket.removeListener('event:new_notification', onNewNotification);
|
||||||
requireAndCall('onNewNotification', data);
|
socket.on('event:new_notification', onNewNotification);
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('event:notifications.updateCount', function (data) {
|
socket.removeListener('event:notifications.updateCount', onUpdateCount);
|
||||||
requireAndCall('updateNotifCount', data);
|
socket.on('event:notifications.updateCount', onUpdateCount);
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function onNewNotification(data) {
|
||||||
|
requireAndCall('onNewNotification', data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onUpdateCount(data) {
|
||||||
|
requireAndCall('updateNotifCount', data);
|
||||||
|
}
|
||||||
|
|
||||||
function requireAndCall(method, param) {
|
function requireAndCall(method, param) {
|
||||||
require(['notifications'], function (notifications) {
|
require(['notifications'], function (notifications) {
|
||||||
notifications[method](param);
|
notifications[method](param);
|
||||||
|
|||||||
Reference in New Issue
Block a user