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 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-02-12 14:28:57 +01:00
parent aa13473b94
commit 5cd067ae6f

View file

@ -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);
}
}
}
}