Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions Room/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,38 @@ export class Room {
}
}


async deleteAllStates(roomKey) {
try {
await this.ensureStorage();
const room = await this.getRoom(roomKey);

if(!this.hasDrawings(roomKey)) {
alert('No drawings found.')
return
}

const updatedStates = []
const updatedRoom = {
...room,
states: updatedStates,
lastModified: Date.now()
};

await roomDB.put(roomKey, updatedRoom);
console.log(`All states deleted from room:`, roomKey);
NetworkManager.broadcast({
t: 'all_states_deleted',
from: state.localPeerId,
roomKey,
});
return updatedStates;
} catch (error) {
console.error('Error deleting states:', error);
return false;
}
}

async getRoomState(roomKey) {
await this.ensureStorage();
const room = await this.getRoom(roomKey);
Expand Down Expand Up @@ -305,10 +337,6 @@ export class Room {
}
}

async deleteDrawings(roomKey) {
return null
}

async getAllRooms() {
await this.ensureStorage();

Expand Down
Loading