From 365fc519903fa2b4e8c593eed6cc5f5f77b5332a Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Wed, 30 Sep 2026 14:25:52 +0200 Subject: [PATCH] fix: hand floating chat reminders over to the BGS rail --- viewer/scripts/protocol-smoke.mjs | 10 ++++++++++ viewer/src/game-chat.ts | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/viewer/scripts/protocol-smoke.mjs b/viewer/scripts/protocol-smoke.mjs index 426a7a2..9d64b95 100644 --- a/viewer/scripts/protocol-smoke.mjs +++ b/viewer/scripts/protocol-smoke.mjs @@ -173,6 +173,16 @@ try { 'history refresh preserves known unread' ); await page.waitForFunction(() => !document.querySelector('.chat-shortcut').hidden); + await page.evaluate(() => host.emit('preferences', { sound: false, chatNotifications: false })); + await page.waitForFunction(() => document.querySelector('.chat-shortcut').hidden); + assert.match( + await panel.locator('summary').textContent(), + /1 unread/, + 'sidebar visibility keeps messages unread' + ); + await page.evaluate(() => host.emit('preferences', { sound: false, chatNotifications: true })); + await page.waitForFunction(() => !document.querySelector('.chat-shortcut').hidden); + assert.match(await shortcut.textContent(), /Chat\s*1$/, 'shortcut shows the unread count'); const shortcutBox = await shortcut.boundingBox(); assert.equal( diff --git a/viewer/src/game-chat.ts b/viewer/src/game-chat.ts index c210a62..16d5f83 100644 --- a/viewer/src/game-chat.ts +++ b/viewer/src/game-chat.ts @@ -67,6 +67,7 @@ export function mountGameChat(emitter: ViewerEmitter, host: Element): let players: { id: number; name: string; color?: string; faction?: string }[] = []; let localPlayer: number | undefined; let chatVisible = false; + let chatNotifications = true; let analysis = false; const shortcut = document.createElement('button'); shortcut.type = 'button'; @@ -149,7 +150,7 @@ export function mountGameChat(emitter: ViewerEmitter, host: Element): const count = chat.unread; const label = count ? `Chat ยท ${count} unread` : 'Chat'; shortcutCount.textContent = String(count); - shortcut.hidden = analysis || chatVisible || !count; + shortcut.hidden = !chatNotifications || analysis || chatVisible || !count; shortcut.setAttribute('aria-label', `Open ${label}`); chatTab.textContent = label; positionShortcut(); @@ -161,6 +162,7 @@ export function mountGameChat(emitter: ViewerEmitter, host: Element): const dispose = [ detach, emitter.on('preferences', (preferences) => { + chatNotifications = preferences.chatNotifications !== false; analysis = preferences.analysis === true; slot.hidden = analysis; tabs.style.display = analysis ? 'none' : '';