refactor: use utils.debounce

fixes socket message spam in chat resize
This commit is contained in:
Barış Soner Uşaklı
2021-10-04 10:58:32 -04:00
parent 840b49b9b2
commit a7668a7fb1
9 changed files with 68 additions and 119 deletions

View File

@@ -30,6 +30,7 @@ define('forum/chats', [
Chats.addEventListeners();
Chats.resizeMainWindow();
Chats.setActive();
if (env === 'md' || env === 'lg') {
Chats.addHotkeys();
@@ -452,7 +453,7 @@ define('forum/chats', [
};
Chats.addGlobalEventListeners = function () {
$(window).on('resize', Chats.resizeMainWindow);
$(window).on('resize', utils.throttle(Chats.resizeMainWindow, 100));
$(window).on('mousemove keypress click', function () {
if (newMessage && ajaxify.data.roomId) {
socket.emit('modules.chats.markRead', ajaxify.data.roomId);
@@ -514,8 +515,6 @@ define('forum/chats', [
}
$('.chats-full').height(viewportHeight - fromTop - 1);
Chats.setActive();
};
Chats.setActive = function () {