fix: hand floating chat reminders over to the BGS rail
This commit is contained in:
parent
8c53d1b10e
commit
d14d57437a
2 changed files with 11 additions and 1 deletions
|
|
@ -234,6 +234,11 @@ try {
|
|||
// Visibility follows the chat panel's animation-frame measurement.
|
||||
await page.locator('.chat-shortcut').waitFor({ state: 'visible' });
|
||||
assert.equal(await page.locator('.chat-shortcut').isVisible(), true, 'unread messages show the shortcut');
|
||||
await page.evaluate(() => host.emit('preferences', { sound: false, chatNotifications: false }));
|
||||
await page.locator('.chat-shortcut').waitFor({ state: 'hidden' });
|
||||
assert.match(await panel.locator('summary').textContent(), /1 unread/);
|
||||
await page.evaluate(() => host.emit('preferences', { sound: false, chatNotifications: true }));
|
||||
await page.locator('.chat-shortcut').waitFor({ state: 'visible' });
|
||||
assert.equal(await list.locator('article').count(), 36, 'duplicate append is ignored');
|
||||
await page.evaluate((messages) => host.emit('chat:messages', messages), [...messages, incoming]);
|
||||
assert.match(
|
||||
|
|
|
|||
|
|
@ -59,6 +59,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;
|
||||
const shortcut = document.createElement('button');
|
||||
shortcut.type = 'button';
|
||||
shortcut.className = 'chat-shortcut';
|
||||
|
|
@ -146,7 +147,7 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
|
|||
const label = count ? `Chat · ${count} unread` : 'Chat';
|
||||
chatTab.textContent = count ? `Chat · ${count}` : 'Chat';
|
||||
shortcut.textContent = label;
|
||||
shortcut.hidden = count === 0 || chatVisible;
|
||||
shortcut.hidden = !chatNotifications || count === 0 || chatVisible;
|
||||
shortcut.setAttribute('aria-label', `Open ${label}`);
|
||||
}
|
||||
shortcut.onclick = () => selectPanel('chat');
|
||||
|
|
@ -162,6 +163,10 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
|
|||
const dispose = [
|
||||
() => mobile.removeEventListener('change', expandMobilePanels),
|
||||
detach,
|
||||
emitter.on('preferences', (preferences) => {
|
||||
chatNotifications = preferences.chatNotifications !== false;
|
||||
updateShortcut();
|
||||
}),
|
||||
chat.subscribe(updateShortcut),
|
||||
emitter.on('state', (state) => {
|
||||
players = (state?.players || []).map((player: any, index: number) => ({ ...player, id: index }));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue