debug(matrix): add logging for room restoration

This commit is contained in:
Till-JS 2026-02-12 14:32:46 +01:00
parent 5cd067ae6f
commit 8768d6276c

View file

@ -265,13 +265,22 @@ class MatrixStore {
// Restore last selected room
if (browser && !this._currentRoomId) {
const lastRoomId = localStorage.getItem(LAST_ROOM_KEY);
console.log(
`[Matrix] Restore check: lastRoomId=${lastRoomId}, rooms=${this._rooms.length}`
);
if (lastRoomId) {
// Check if room exists in loaded rooms
const roomExists = this._rooms.some((r) => r.roomId === lastRoomId);
console.log(`[Matrix] Room exists: ${roomExists}`);
if (roomExists) {
console.log(`[Matrix] Restoring room: ${lastRoomId}`);
this.selectRoom(lastRoomId);
}
}
} else {
console.log(
`[Matrix] Skip restore: browser=${browser}, currentRoomId=${this._currentRoomId}`
);
}
}
@ -473,6 +482,7 @@ class MatrixStore {
* Select a room to view
*/
selectRoom(roomId: string) {
console.log(`[Matrix] selectRoom called: ${roomId}`);
this._currentRoomId = roomId;
const room = this._client?.getRoom(roomId);
@ -488,8 +498,10 @@ class MatrixStore {
// Save last room to localStorage
if (browser) {
localStorage.setItem(LAST_ROOM_KEY, roomId);
console.log(`[Matrix] Saved to localStorage: ${roomId}`);
}
} else {
console.log(`[Matrix] Room not found by getRoom: ${roomId}`);
this._timeline = [];
}
}