fix: consolidate audited dev updates

This commit is contained in:
illusia committed 2026-10-08 10:32:59 +08:00
1 parent 568b8fd8be
commit 0a552f7ee8
58 files changed
+1930 -132

No files matched your search

+15 -1
View File
@@ -5,7 +5,8 @@ type DirectoryDelta =
| { type: "clientEnter"; info: ClientInfo }
| { type: "clientLeave"; id: number }
| { type: "clientMoved"; id: number; channelID: bigint }
| { type: "clientUpdated"; info: DirectoryClientInfo };
| { type: "clientUpdated"; info: DirectoryClientInfo }
| { type: "clientListSnapshot"; clients: DirectoryClientInfo[] };
/**
* Merges staged welcome snapshots with events received while the snapshot is
@@ -52,6 +53,10 @@ export class DirectorySynchronizer {
this.applyOrQueue({ type: "clientUpdated", info });
}
applyClientListSnapshot(clients: DirectoryClientInfo[]): void {
this.applyOrQueue({ type: "clientListSnapshot", clients });
}
getSnapshot(): TSDirectorySnapshot | null {
if (!this.snapshot) return null;
return {
@@ -92,6 +97,15 @@ export class DirectorySynchronizer {
this.clients.set(delta.info.id, current ? { ...current, ...delta.info } : delta.info);
return;
}
if (delta.type === "clientListSnapshot") {
for (const info of delta.clients) {
const current = this.clients.get(info.id);
// A refresh enriches known members; it must not resurrect someone who
// left while the asynchronous list request was in flight.
if (current && !this.departedClientIds.has(info.id)) this.clients.set(info.id, { ...current, ...info });
}
return;
}
const current = this.clients.get(delta.id);
if (current) this.clients.set(delta.id, { ...current, channelID: delta.channelID });
}