Track last chatMsg time, and ignore reconnect spam

This commit is contained in:
Xaekai 2022-02-12 17:41:18 -08:00
parent 5ecca27c9f
commit e713eca9cc
3 changed files with 12 additions and 1 deletions

View File

@ -1170,6 +1170,8 @@ const Callbacks = {
window.Callbacks = Callbacks; window.Callbacks = Callbacks;
// For sanity, do this
// localStorage.setItem('cytube_socket_omissions', '["mediaUpdate"]')
var SOCKET_DEBUG = { var SOCKET_DEBUG = {
enabled: (localStorage.getItem('cytube_socket_debug') === 'true'), enabled: (localStorage.getItem('cytube_socket_debug') === 'true'),
omit: (((data)=>{ omit: (((data)=>{

View File

@ -49,7 +49,8 @@ var CHATMAXSIZE = 100;
var SCROLLCHAT = true; var SCROLLCHAT = true;
var IGNORE_SCROLL_EVENT = false; var IGNORE_SCROLL_EVENT = false;
var LASTCHAT = { var LASTCHAT = {
name: "" name: "",
time: 0
}; };
var FOCUSED = true; var FOCUSED = true;
var PAGETITLE = "CyTube"; var PAGETITLE = "CyTube";

View File

@ -1563,6 +1563,14 @@ function addChatMessage(data) {
if (data.meta.shadow && !USEROPTS.show_shadowchat) { if (data.meta.shadow && !USEROPTS.show_shadowchat) {
return; 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 msgBuf = $("#messagebuffer");
var div = formatChatMessage(data, LASTCHAT); var div = formatChatMessage(data, LASTCHAT);
// Incoming: a bunch of crap for the feature where if you hover over // Incoming: a bunch of crap for the feature where if you hover over