From e713eca9cc7a8ee3f7951eb4a1619eadc62fc3e6 Mon Sep 17 00:00:00 2001 From: Xaekai Date: Sat, 12 Feb 2022 17:41:18 -0800 Subject: [PATCH] Track last chatMsg time, and ignore reconnect spam --- www/js/callbacks.js | 2 ++ www/js/data.js | 3 ++- www/js/util.js | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 43a86929..8b141ccb 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -1170,6 +1170,8 @@ const Callbacks = { window.Callbacks = Callbacks; +// For sanity, do this +// localStorage.setItem('cytube_socket_omissions', '["mediaUpdate"]') var SOCKET_DEBUG = { enabled: (localStorage.getItem('cytube_socket_debug') === 'true'), omit: (((data)=>{ diff --git a/www/js/data.js b/www/js/data.js index dac3e96c..2c107ae5 100644 --- a/www/js/data.js +++ b/www/js/data.js @@ -49,7 +49,8 @@ var CHATMAXSIZE = 100; var SCROLLCHAT = true; var IGNORE_SCROLL_EVENT = false; var LASTCHAT = { - name: "" + name: "", + time: 0 }; var FOCUSED = true; var PAGETITLE = "CyTube"; diff --git a/www/js/util.js b/www/js/util.js index ffee5957..d8ecb5d5 100644 --- a/www/js/util.js +++ b/www/js/util.js @@ -1563,6 +1563,14 @@ function addChatMessage(data) { if (data.meta.shadow && !USEROPTS.show_shadowchat) { return; } + // This is so we discard repeated messages + // which become annoying when the user is experiencing repeated socketio reconnects + if (data.time < LASTCHAT.time) { + return; + } else { + LASTCHAT.time = data.time; + } + var msgBuf = $("#messagebuffer"); var div = formatChatMessage(data, LASTCHAT); // Incoming: a bunch of crap for the feature where if you hover over