From 2fea81d46b61396a8014a44827afec0297a1417e Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 11 Mar 2026 01:11:05 -0400 Subject: [PATCH] fixc --- client/public/data.js | 5 +++-- client/public/wsModule.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/public/data.js b/client/public/data.js index 152af2b..39daafd 100644 --- a/client/public/data.js +++ b/client/public/data.js @@ -128,8 +128,9 @@ function addMessage({ /** * Insert a system notice as a root‐level thread item. * @param {string} content — HTML or plain text for the notice + * @param {boolean} [shouldNotify=true] — whether to trigger a browser notification */ -function addNotice(content) { +function addNotice(content, shouldNotify = true) { const ts = Math.floor(Date.now() / 1000); const id = String(noticeCounter--); threads.set(id, { @@ -141,7 +142,7 @@ function addNotice(content) { children: [], }); rootIds.push(id); - notifyNotice(content); + if (shouldNotify) notifyNotice(content); } /** diff --git a/client/public/wsModule.js b/client/public/wsModule.js index 27e4025..66514bf 100644 --- a/client/public/wsModule.js +++ b/client/public/wsModule.js @@ -87,6 +87,7 @@ export function initWebSocket( addUser(String(id), name); addNotice( `${new Option(name).innerHTML} joined.`, + false, ); const groups = getGroupedUsers(); usersListEl.innerHTML = "Online: " + groups.join(", "); @@ -98,6 +99,7 @@ export function initWebSocket( const lastName = users.get(sid) || name; addNotice( `${new Option(lastName).innerHTML} left.`, + false, ); removeUser(sid); const groups = getGroupedUsers(); @@ -200,7 +202,7 @@ export function initWebSocket( }; socket.onclose = () => { - addNotice("Disconnected."); + addNotice("Disconnected.", false); renderChat(chatEl, inputContainer); };