[Upd] User states

This commit is contained in:
Alex 2026-08-07 23:05:26 +02:00
commit ec019a4dff
Signed by: alex
SSH key fingerprint: SHA256:D1+Ub8o0v4K5y1JNivW8IxEOelqLSvPmUzBbDIoZkRQ
16 changed files with 667 additions and 87 deletions

19
packages/cache/src/sync.test.tsx vendored Normal file
View file

@ -0,0 +1,19 @@
import { describe, expect, it } from "vitest";
import { removeMissingContactSnapshots } from "./sync";
describe("authoritative contact cache updates", () => {
it("removes missing users and keeps the latest authoritative set", () => {
const contacts = [{ UserId: 2 }, { UserId: 3 }, { UserId: 4 }];
expect(removeMissingContactSnapshots(contacts, [3, 99])).toEqual([
{ UserId: 2 },
{ UserId: 4 },
]);
});
it("does not let a delayed state notification recreate a removed contact", () => {
const contacts = [{ UserId: 2 }];
const afterMissing = removeMissingContactSnapshots(contacts, [2]);
expect(removeMissingContactSnapshots(afterMissing, [])).toEqual([]);
});
});