fix(viewer): restore saved unread chat counts

This commit is contained in:
coyotte508 2026-09-26 12:10:31 +02:00
commit 524ceec01c
4 changed files with 28 additions and 8 deletions

View file

@ -1,6 +1,6 @@
{
"name": "fuji-viewer",
"version": "0.1.6",
"version": "0.1.7",
"private": true,
"license": "AGPL-3.0-only",
"type": "module",
@ -11,7 +11,7 @@
"test:tutorial": "node --test src/tutorial/*.spec.ts"
},
"dependencies": {
"@boardgamers/protocol": "0.6.0",
"@boardgamers/protocol": "0.6.1",
"fuji-engine": "workspace:*"
},
"devDependencies": {

10
pnpm-lock.yaml generated
View file

@ -34,8 +34,8 @@ importers:
packages/viewer:
dependencies:
'@boardgamers/protocol':
specifier: 0.6.0
version: 0.6.0
specifier: 0.6.1
version: 0.6.1
fuji-engine:
specifier: workspace:*
version: link:../engine
@ -61,8 +61,8 @@ importers:
packages:
'@boardgamers/protocol@0.6.0':
resolution: {integrity: sha512-byHV2eOOFpnQCnhLaM0LPUpT30ew1aAOuTIYxwztkVjg4NgeTyPwjU8Efmc/xi+DGCrfIjo2LTb7YlNUhmzy0g==}
'@boardgamers/protocol@0.6.1':
resolution: {integrity: sha512-/SdqqYrRUNizjGqQygR4kxTZqCOqWfj190Uj/YHI8i0pD4eNXGofZJd2QhkB63n0iSRHMvJJRJReadof151wBg==}
'@jridgewell/gen-mapping@0.3.13':
resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}
@ -631,7 +631,7 @@ packages:
snapshots:
'@boardgamers/protocol@0.6.0':
'@boardgamers/protocol@0.6.1':
dependencies:
zod: 4.6.2

View file

@ -1,4 +1,4 @@
packages:
- packages/*
minimumReleaseAgeExclude:
- "@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0"
- "@boardgamers/protocol@0.2.2 || 0.3.0 || 0.3.1 || 0.3.3 || 0.4.0 || 0.4.2 || 0.5.0 || 0.6.0 || 0.6.1"

View file

@ -94,6 +94,26 @@ try {
);
await page.waitForTimeout(650);
assert.equal(await page.evaluate(() => window.events.filter((e) => e.name === "chat:read").length), receipts + 1);
await page.getByRole("button", { name: "Collapse chat" }).click();
await page.evaluate(() => {
window.restoredReceipts = [];
bridge.on("chat:read", (payload) => restoredReceipts.push(payload));
bridge.emit("chat:state", { canSend: true, readState: { userId: "self", lastReadAt: 500000 } });
bridge.emit("chat:messages", [
{ _id: "000001f40000000000000001", type: "text", authorId: "other", text: "Already read" },
{ _id: "000001f50000000000000001", type: "text", authorId: "other", text: "Unread after reload" },
{ _id: "000001f60000000000000001", type: "text", authorId: "self", text: "My own message" },
{ _id: "000001f70000000000000001", type: "system", text: "Game started" },
]);
});
await page.waitForFunction(() => document.querySelector(".utility-count")?.textContent === "1");
await page.waitForTimeout(650);
assert.equal(await page.evaluate(() => restoredReceipts.length), 0, "collapsed chat preserves unread history");
await page.getByRole("button", { name: "Expand chat" }).click();
await page.locator(".chat-messages").scrollIntoViewIfNeeded();
await page.waitForFunction(() => restoredReceipts.length > 0);
assert.equal(await page.locator(".utility-count").count(), 0, "opening chat clears restored unread");
await page.screenshot({ path: "work/chat-desktop.png" });
await page.evaluate(() => window.bridge.emit("chat:disabled", true));
assert.equal(await page.getByRole("textbox", { name: "Chat message" }).count(), 0);