fix: hand floating chat reminders over to the BGS rail

This commit is contained in:
coyotte508 2026-09-30 14:25:52 +02:00
commit 365fc51990
2 changed files with 13 additions and 1 deletions

View file

@ -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(

View file

@ -67,6 +67,7 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, 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<any, any>, 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<any, any>, 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' : '';