From 7f803012762e54334784d60e7d7b2494dd0e28db Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 9 Mar 2025 18:05:39 +0200 Subject: [PATCH] web/statestore: reload room view if state store is cleared --- web/src/api/statestore/main.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/src/api/statestore/main.ts b/web/src/api/statestore/main.ts index 08b3422..160b643 100644 --- a/web/src/api/statestore/main.ts +++ b/web/src/api/statestore/main.ts @@ -256,8 +256,10 @@ export class StateStore { } applySync(sync: SyncCompleteData) { + let prevActiveRoom: RoomID | null = null if (sync.clear_state && this.rooms.size > 0) { console.info("Clearing state store as sync told to reset and there are rooms in the store") + prevActiveRoom = this.activeRoomID this.clear() } const resyncRoomList = this.roomList.current.length === 0 @@ -388,6 +390,10 @@ export class StateStore { this.topLevelSpaces.emit(sync.top_level_spaces) this.spaceOrphans.children = sync.top_level_spaces.map(child_id => ({ child_id })) } + if (prevActiveRoom) { + // TODO this will fail if the room is not in the top 100 recent rooms + this.switchRoom?.(prevActiveRoom) + } } invalidateEmojiPackKeyCache() {