From aebd9278c2abac1d11dae2edd2a3aeb30a635f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 6 Sep 2023 17:01:09 -0400 Subject: [PATCH 1/2] refactor: reduce socket.emits for typing if textarea changess between empty/full emit right away --- public/src/client/chats.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 20e81eb854..53a2835e9a 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -331,9 +331,22 @@ define('forum/chats', [ textarea.on('focus', () => textarea.val() && emitTyping(true)); textarea.on('blur', () => emitTyping(false)); - textarea.on('input', utils.throttle(function () { - emitTyping(!!textarea.val()); - }, 2500, true)); + let timeoutid = 0; + let hasText = !!textarea.val(); + textarea.on('input', function () { + const _hasText = !!textarea.val(); + if (_hasText !== hasText) { + clearTimeout(timeoutid); + timeoutid = 0; + hasText = _hasText; + emitTyping(hasText); + } else if (!timeoutid) { + timeoutid = setTimeout(() => { + emitTyping(!!textarea.val()); + timeoutid = 0; + }, 5000); + } + }); }; Chats.addActionHandlers = function (element, roomId) { From d7a7c3553cbc6b17bde65a5a7ff193159070d523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Wed, 6 Sep 2023 18:31:35 -0400 Subject: [PATCH 2/2] chore: up themes --- install/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/package.json b/install/package.json index 83dc54d8dc..0372aea609 100644 --- a/install/package.json +++ b/install/package.json @@ -102,10 +102,10 @@ "nodebb-plugin-ntfy": "1.6.1", "nodebb-plugin-spam-be-gone": "2.1.1", "nodebb-rewards-essentials": "0.2.3", - "nodebb-theme-harmony": "1.1.52", + "nodebb-theme-harmony": "1.1.53", "nodebb-theme-lavender": "7.1.3", "nodebb-theme-peace": "2.1.18", - "nodebb-theme-persona": "13.2.27", + "nodebb-theme-persona": "13.2.28", "nodebb-widget-essentials": "7.0.13", "nodemailer": "6.9.5", "nprogress": "0.2.0",