fixed issues namely reveloved around chat

This commit is contained in:
JCEEE
2026-08-25 10:54:18 +01:00
parent f63e2918ff
commit e904bb8210
5 changed files with 96 additions and 38 deletions
+26 -9
View File
@@ -50,21 +50,38 @@ class ChatStore {
});
async init(opts: ChatInit) {
// Re-initialize whenever the family OR the actor changes (e.g. switching
// between parent and child in the same browser session). The store is a
// module singleton — keeping the previous actor's identity/subscription
// would make one direction's realtime silently dead.
const sameIdentity =
this.initialized &&
this.famId === opts.famId &&
this.actorId === opts.actorId &&
this.actorType === opts.actorType;
if (sameIdentity) return;
if (this.initPromise) {
await this.initPromise;
if (
this.initialized &&
this.famId === opts.famId &&
this.actorId === opts.actorId &&
this.actorType === opts.actorType
)
return;
}
this.cleanup();
this.destroyed = false;
this.famId = opts.famId;
this.actorId = opts.actorId;
this.actorType = opts.actorType;
this.actorName = opts.actorName;
this.actorColor = opts.actorColor;
this.pbToken = opts.pbToken || '';
if (this.initialized && this.famId === opts.famId) return;
if (this.initPromise) {
await this.initPromise;
if (this.initialized && this.famId === opts.famId) return;
}
this.cleanup();
this.destroyed = false;
this.messages = [];
this.typing = {};
this.unread = 0;
this.lastSeenAt = Date.now();
this.initPromise = (async () => {