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:
Jannis Braun
2026-04-08 01:02:15 +02:00
parent a496dc01bd
commit fa5dbbfd4f
+6 -2
View File
@@ -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 const existingFederatedIds = new Map<string, string>(); // federatedId → dmChannelId
for (const dm of get().dmChannels) { for (const dm of get().dmChannels) {
if (dm.federatedId) { 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);
}
} }
} }