Show floating chat shortcut only for unread messages

This commit is contained in:
coyotte508 2026-09-15 11:50:39 +02:00
commit 9601fac15e
2 changed files with 4 additions and 1 deletions

View file

@ -119,6 +119,7 @@ try {
el.open = false;
});
await page.evaluate(() => window.scrollTo(0, 0));
await page.waitForFunction(() => document.querySelector('.chat-shortcut').hidden);
const incoming = {
_id: id(40),
type: 'text',
@ -136,6 +137,7 @@ try {
host.emit('chat:appended', [incoming]);
}, incoming);
assert.match(await panel.locator('summary').textContent(), /1 unread/);
assert.equal(await page.locator('.chat-shortcut').isVisible(), true, 'unread messages show the shortcut');
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(
@ -165,6 +167,7 @@ try {
await list.locator('.chat-mention').click();
assert.deepEqual(await page.evaluate(() => playerClicks), [{ index: 0 }]);
await page.waitForFunction(() => receipts.some((r) => r.messageId === '000000000000000000000028'));
await page.waitForFunction(() => document.querySelector('.chat-shortcut').hidden);
const receiptCount = await page.evaluate(() => receipts.length);
await list.evaluate((el) => {
el.scrollTop = 0;

View file

@ -77,7 +77,7 @@ export function mountGameChat(emitter: ViewerEmitter<any, any>, host: Element):
const count = chat.unread;
const label = count ? `Chat · ${count} unread` : 'Chat';
shortcut.textContent = label;
shortcut.hidden = chatVisible;
shortcut.hidden = count === 0 || chatVisible;
shortcut.setAttribute('aria-label', `Open ${label}`);
}
shortcut.onclick = () => {