mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-18 23:10:16 +02:00
store all rooms
This commit is contained in:
@@ -142,10 +142,7 @@ class RoomManager {
|
|||||||
|
|
||||||
filteredRooms.unshift(newRoom);
|
filteredRooms.unshift(newRoom);
|
||||||
|
|
||||||
// Limit to the most recent 20 rooms
|
await this.saveRooms(filteredRooms);
|
||||||
const limitedRooms = filteredRooms.slice(0, 20);
|
|
||||||
|
|
||||||
await this.saveRooms(limitedRooms);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRooms(): Promise<CollabRoom[]> {
|
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> {
|
async clearAllRooms(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem(ROOM_STORAGE_KEY);
|
localStorage.removeItem(ROOM_STORAGE_KEY);
|
||||||
|
Reference in New Issue
Block a user