store all rooms

This commit is contained in:
Ryan Di
2025-06-02 13:07:14 +10:00
parent 97cc331530
commit ca5c34ac48

View File

@@ -142,10 +142,7 @@ class RoomManager {
filteredRooms.unshift(newRoom);
// Limit to the most recent 20 rooms
const limitedRooms = filteredRooms.slice(0, 20);
await this.saveRooms(limitedRooms);
await this.saveRooms(filteredRooms);
}
async getRooms(): Promise<CollabRoom[]> {
@@ -179,6 +176,16 @@ class RoomManager {
}
}
async getCurrentRoom(): Promise<CollabRoom | null> {
const rooms = await this.loadRooms();
if (rooms.length === 0) {
return null;
}
// Return the most recently accessed room
return rooms.sort((a, b) => b.lastAccessed - a.lastAccessed)[0];
}
async clearAllRooms(): Promise<void> {
try {
localStorage.removeItem(ROOM_STORAGE_KEY);