diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index e8803762..79ed9d3c 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -92,15 +92,6 @@ export class GameRoom { return gameRoom; } - public getGroups(): Group[] { - return Array.from(this.groups.values()); - } - - public getGroupIncludingUser(user: User): Group | undefined { - const foundGroups = this.getGroups().filter((grp) => grp.includes(user)); - return foundGroups[0]; - } - public getUsers(): Map { return this.users; } @@ -239,13 +230,11 @@ export class GameRoom { } public sendToOthersInGroupIncludingUser(user: User, message: ServerToClientMessage): void { - this.getGroupIncludingUser(user) - ?.getUsers() - .forEach((currentUser: User) => { - if (currentUser.name !== user.name) { - currentUser.socket.write(message); - } - }); + user.group?.getUsers().forEach((currentUser: User) => { + if (currentUser.name !== user.name) { + currentUser.socket.write(message); + } + }); } public sendToUserWithName(name: string, message: ServerToClientMessage): void { diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index 727cf430..5818afa9 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -860,8 +860,7 @@ export class SocketManager { room.sendToOthersInGroupIncludingUser(user, clientMessage); // Update followers - const group = room.getGroupIncludingUser(user); - group?.getUsers().forEach((user) => { + user.group?.getUsers().forEach((user) => { user.following = []; }); } else {