From 65f4404b8265dc764bc6b02df208cbe2e755321b Mon Sep 17 00:00:00 2001 From: kakiba <97882386+kotto5@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:25:58 +0900 Subject: [PATCH] =?UTF-8?q?[backend]=20user=20=E3=81=8C=E5=B1=85=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E6=99=82=E3=81=AE=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=83=8F=E3=83=B3=E3=83=89=E3=83=AA=E3=83=B3=E3=82=B0?= =?UTF-8?q?=E3=82=92=E9=81=A9=E5=88=87=E3=81=AB=E8=A1=8C=E3=81=86=20(#285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/chat/chat.service.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/chat/chat.service.ts b/backend/src/chat/chat.service.ts index 3b165feb..f000cdf6 100644 --- a/backend/src/chat/chat.service.ts +++ b/backend/src/chat/chat.service.ts @@ -212,13 +212,15 @@ export class ChatService { } handleDisconnect(client: Socket) { - const emitData = { - userId: this.getUserId(client), - status: UserStatus.Offline, - name: this.getUser(client)?.name, - }; - if (emitData.userId) { - client.broadcast.emit('online-status', [emitData]); + const user = this.getUser(client); + if (user) { + client.broadcast.emit('online-status', [ + { + userId: user.id, + status: UserStatus.Offline, + name: user.name, + }, + ]); } this.removeClient(client); }