From 5cd067ae6f87b4cc4f557832f13b435b52f54c99 Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:28:57 +0100 Subject: [PATCH] fix(matrix): check _rooms array for last room restoration Use _rooms.some() instead of getRoom() to check if the last selected room exists, as the client's internal room cache may not be populated yet at PREPARED state. Co-Authored-By: Claude Opus 4.5 --- apps/matrix/apps/web/src/lib/matrix/store.svelte.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/matrix/apps/web/src/lib/matrix/store.svelte.ts b/apps/matrix/apps/web/src/lib/matrix/store.svelte.ts index a1ba8c312..6fe8c3e7d 100644 --- a/apps/matrix/apps/web/src/lib/matrix/store.svelte.ts +++ b/apps/matrix/apps/web/src/lib/matrix/store.svelte.ts @@ -265,8 +265,12 @@ class MatrixStore { // Restore last selected room if (browser && !this._currentRoomId) { const lastRoomId = localStorage.getItem(LAST_ROOM_KEY); - if (lastRoomId && this._client!.getRoom(lastRoomId)) { - this.selectRoom(lastRoomId); + if (lastRoomId) { + // Check if room exists in loaded rooms + const roomExists = this._rooms.some((r) => r.roomId === lastRoomId); + if (roomExists) { + this.selectRoom(lastRoomId); + } } } }