due to no refresh on login socket listeners were added more than once,
so remove them before adding the listeners
v1.18.x
Baris Usakli 6 years ago
parent 8566205214
commit 8da3b2a487

@ -18,18 +18,27 @@ define('forum/header/chat', ['components'], function (components) {
requireAndCall('loadChatsDropdown', chatsListEl);
}
socket.on('event:chats.receive', function (data) {
socket.removeListener('event:chats.receive', onChatMessageReceived);
socket.on('event:chats.receive', onChatMessageReceived);
socket.removeListener('event:user_status_change', onUserStatusChange);
socket.on('event:user_status_change', onUserStatusChange);
socket.removeListener('event:chats.roomRename', onRoomRename);
socket.on('event:chats.roomRename', onRoomRename);
};
function onChatMessageReceived(data) {
requireAndCall('onChatMessageReceived', data);
});
}
socket.on('event:user_status_change', function (data) {
function onUserStatusChange(data) {
requireAndCall('onUserStatusChange', data);
});
}
socket.on('event:chats.roomRename', function (data) {
function onRoomRename(data) {
requireAndCall('onRoomRename', data);
});
};
}
function requireAndCall(method, param) {
require(['chat'], function (chat) {

@ -21,14 +21,20 @@ define('forum/header/notifications', ['components'], function (components) {
requireAndCall('loadNotifications', notifList);
}
socket.on('event:new_notification', function (data) {
socket.removeListener('event:new_notification', onNewNotification);
socket.on('event:new_notification', onNewNotification);
socket.removeListener('event:notifications.updateCount', onUpdateCount);
socket.on('event:notifications.updateCount', onUpdateCount);
};
function onNewNotification(data) {
requireAndCall('onNewNotification', data);
});
}
socket.on('event:notifications.updateCount', function (data) {
function onUpdateCount(data) {
requireAndCall('updateNotifCount', data);
});
};
}
function requireAndCall(method, param) {
require(['notifications'], function (notifications) {

Loading…
Cancel
Save