diff --git a/back/src/Model/Group.ts b/back/src/Model/Group.ts index 16cd5ffe..4c597557 100644 --- a/back/src/Model/Group.ts +++ b/back/src/Model/Group.ts @@ -68,7 +68,7 @@ export class Group { leave(user: UserInterface): void { - let success = this.users.delete(user); + const success = this.users.delete(user); if (success === false) { throw new Error("Could not find user "+user.id+" in the group "+this.id); } @@ -84,7 +84,7 @@ export class Group { */ destroy(): void { - for (let user of this.users) { + for (const user of this.users) { this.leave(user); } } diff --git a/back/src/Model/World.ts b/back/src/Model/World.ts index e4ce5c32..6d4fc205 100644 --- a/back/src/Model/World.ts +++ b/back/src/Model/World.ts @@ -20,7 +20,7 @@ export class World { // Users, sorted by ID private readonly users: Map; - private readonly groups: Map; + private readonly groups: Set; private readonly connectCallback: ConnectCallback; private readonly disconnectCallback: DisconnectCallback; @@ -35,7 +35,7 @@ export class World { groupDeletedCallback: GroupDeletedCallback) { this.users = new Map(); - this.groups = new Map(); + this.groups = new Set(); this.connectCallback = connectCallback; this.disconnectCallback = disconnectCallback; this.minDistance = minDistance; @@ -99,7 +99,7 @@ export class World { user, closestUser ], this.connectCallback, this.disconnectCallback); - this.groups.set(group.getId(), group); + this.groups.add(group); } } @@ -132,10 +132,10 @@ export class World { if (group.isEmpty()) { this.groupDeletedCallback(group.getId(), user); group.destroy(); - if (!this.groups.has(group.getId())) { + if (!this.groups.has(group)) { throw new Error("Could not find group "+group.getId()+" referenced by user "+user.id+" in World."); } - this.groups.delete(group.getId()); + this.groups.delete(group); } else { this.groupUpdatedCallback(group); }