From adb3a5e64e7ec7157a103bfac857b26d4704bbd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 13 Jul 2023 21:40:33 -0400 Subject: [PATCH] fix: client side js crash --- public/src/client/chats.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/src/client/chats.js b/public/src/client/chats.js index ad9147cb3c..f1548dd282 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -32,8 +32,14 @@ define('forum/chats', [ $(window).on('action:ajaxify.start', function () { Chats.destroyAutoComplete(ajaxify.data.roomId); - socket.emit('modules.chats.leave', ajaxify.data.roomId); - socket.emit('modules.chats.leavePublic', ajaxify.data.publicRooms.map(r => r.roomId)); + if (ajaxify.data.template.chats) { + if (ajaxify.data.roomId) { + socket.emit('modules.chats.leave', ajaxify.data.roomId); + } + if (ajaxify.data.publicRooms) { + socket.emit('modules.chats.leavePublic', ajaxify.data.publicRooms.map(r => r.roomId)); + } + } }); Chats.init = function () {