diff --git a/back/src/chat/chat.gateway.ts b/back/src/chat/chat.gateway.ts index 5c1e915..8744fd4 100644 --- a/back/src/chat/chat.gateway.ts +++ b/back/src/chat/chat.gateway.ts @@ -48,10 +48,9 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { socket: socket.id }); if (connect) { + console.log('socket %s has disconnected', socket.id) await this.connectedUserRepository.delete({ user: connect.user }) } - socket.disconnect() - console.log('socket %s has disconnected', socket.id) } @SubscribeMessage('joinChannel') @@ -90,15 +89,16 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { } @SubscribeMessage('leaveChannel') - async onLeaveChannel(socket: Socket): Promise { + async onLeaveChannel(socket: Socket): Promise { + console.log('socket %s has left channel', socket.id) + const connect = await this.connectedUserRepository.findOneBy({ socket: socket.id, }); - if (connect == null) return; + if (connect == null) return false; const channel = await this.chatService.getFullChannel(connect.channel); - socket.disconnect(); if (connect.user === channel.owner.ftId) { - this.server.in(channel.id.toString()).disconnectSockets(); + this.server.in(channel.id.toString()).emit('kicked'); await this.chatService.removeChannel(channel.id); } else { channel.users = channel.users.filter((usr: User) => usr.ftId !== connect.user); @@ -106,6 +106,7 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect { await this.chatService.save(channel); } await this.connectedUserRepository.delete({ socket: socket.id }); + return true; } @SubscribeMessage('addMessage') diff --git a/back/src/chat/message.service.ts b/back/src/chat/message.service.ts index 0968807..366b008 100644 --- a/back/src/chat/message.service.ts +++ b/back/src/chat/message.service.ts @@ -41,6 +41,6 @@ export class MessageService { messages.forEach((msg) => { msg.author.socketKey = '' }) - return messages.filter((m) => !blockeds.includes(m.author.ftId)) + return messages } } diff --git a/back/src/pong/pong.service.ts b/back/src/pong/pong.service.ts index edadad5..c9cf792 100644 --- a/back/src/pong/pong.service.ts +++ b/back/src/pong/pong.service.ts @@ -59,6 +59,7 @@ export class PongService { await this.resultsRepository.save(result) await this.updatePlayer(0, result, nameWhoWon) await this.updatePlayer(1, result, nameWhoWon) + await this.usersService.getLeaderboard() } async getHistory ( diff --git a/back/src/users/users.controller.ts b/back/src/users/users.controller.ts index 52040a8..86c9e39 100644 --- a/back/src/users/users.controller.ts +++ b/back/src/users/users.controller.ts @@ -74,7 +74,7 @@ export class UsersController { user.blocked = user.blocked.filter((usr: User) => { return usr.ftId !== id }) - if (lenBefore === user.blocked.length) throw new BadRequestException('User not found') + if (lenBefore === user.blocked.length) throw new BadRequestException('User not blocked') await this.usersService.save(user) } diff --git a/front/src/App.svelte b/front/src/App.svelte index 1cd2917..3b3c454 100644 --- a/front/src/App.svelte +++ b/front/src/App.svelte @@ -11,7 +11,6 @@ MATCHMAKING = "/matchmaking", PROFILE_ID = "/profile_id", } - @@ -454,7 +473,7 @@
{#each messages as message}

- {#if !blockedUsers.filter((user) => user.username == message.author).length} + {#if !message.hidden} openProfile(message.author.username)} @@ -623,8 +642,7 @@ height: 16px; } - .profile-menu, - .chatMembers { + .profile-menu { position: absolute; background-color: #ffffff; border: 1px solid #dedede;