fix: DMs vanishing after WebSocket reconnection
populateFromReady() built the federatedId dedup set from ALL existing DMs, including those belonging to the reconnecting origin. Incoming DMs then matched their own stale entries and were skipped as "duplicates." The subsequent origin-removal step deleted the old copies, leaving no DMs from that origin in state. Scope the dedup set to DMs from OTHER origins only, so reconnecting origins replace their DMs cleanly while cross-instance dedup still works.
This commit is contained in:
@@ -656,11 +656,15 @@ export const useSpaceStore = create<SpaceState>((set, get) => ({
|
||||
}
|
||||
}
|
||||
|
||||
// Build a set of existing federatedIds for dedup
|
||||
// Build a set of existing federatedIds for dedup (only from OTHER origins —
|
||||
// DMs from the reconnecting origin will be replaced, not deduplicated)
|
||||
const existingFederatedIds = new Map<string, string>(); // federatedId → dmChannelId
|
||||
for (const dm of get().dmChannels) {
|
||||
if (dm.federatedId) {
|
||||
existingFederatedIds.set(dm.federatedId, dm.id);
|
||||
const dmOrigin = get().channelOriginMap.get(dm.id);
|
||||
if (dmOrigin !== origin) {
|
||||
existingFederatedIds.set(dm.federatedId, dm.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user