fixed issues namely reveloved around chat
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user