From 337b5867ecc191c00ad29a1aa2af85f458d1373f Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 1 Sep 2024 10:18:29 -0700 Subject: [PATCH] Corrected an issue with spamming the server and normalized my use of setTimeout v. setInterval. --- evennia/web/static/webclient/js/plugins/is_typing.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/evennia/web/static/webclient/js/plugins/is_typing.js b/evennia/web/static/webclient/js/plugins/is_typing.js index 22480702d1..02bebc0176 100644 --- a/evennia/web/static/webclient/js/plugins/is_typing.js +++ b/evennia/web/static/webclient/js/plugins/is_typing.js @@ -36,6 +36,8 @@ let is_typing = (function () { state.timeout = Date.now() + timeout; clearTimeout(state.callback); state.callback = setTimeout(stoppedTyping, timeout); + + sendIsTyping(); }; const stoppedTyping = function () { @@ -111,7 +113,7 @@ let is_typing = (function () { } if (state.cleanup_callback) { - clearInterval(state.cleanup_callback); + clearTimeout(state.cleanup_callback); } Evennia.msg("is_typing_remove_participant"); @@ -133,7 +135,7 @@ let is_typing = (function () { .forEach((index) => state.typing_players.splice(index, 1)); if (state.typing_players.length === 0) { - clearInterval(state.cleanup_callback); + clearTimeout(state.cleanup_callback); $("#istyping").hide(); } }; @@ -164,7 +166,9 @@ let is_typing = (function () { // Existing talker is still going } else if (updated.state && player.length > 0) { - player[0].timeout = Date.now() + timeout; + if (Date.now() - 1000 >= player.timeout) { + stillTyping(); + } // They're done talking } else { @@ -176,7 +180,7 @@ let is_typing = (function () { }); if (state.typing_players.length > 0 && !state.cleanup_callback) { - state.cleanup_callback = setInterval(cleanupTimedOutPlayers, 100); + state.cleanup_callback = setTimeout(cleanupTimedOutPlayers, 100); $("#istyping").show(); } else if ( state.typing_players.length === 0 &&