From 42ea66c34353ca614b9d3beb760f0b1327840f17 Mon Sep 17 00:00:00 2001 From: Reto Brunner Date: Mon, 8 Apr 2024 07:30:47 +0200 Subject: [PATCH] socket-events/msg: fix errors --- client/js/socket-events/msg.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/js/socket-events/msg.ts b/client/js/socket-events/msg.ts index b07f5e36..392538f9 100644 --- a/client/js/socket-events/msg.ts +++ b/client/js/socket-events/msg.ts @@ -193,7 +193,7 @@ function updateUserList(channel: ClientChan, msg: SharedMsg) { case "message": // fallthrough case "action": { - const user = channel.users.find((u) => u.nick === msg.from.nick); + const user = channel.users.find((u) => u.nick === msg.from?.nick); if (user) { user.lastMessage = new Date(msg.time).getTime() || Date.now(); @@ -205,7 +205,7 @@ function updateUserList(channel: ClientChan, msg: SharedMsg) { case "quit": // fallthrough case "part": { - const idx = channel.users.findIndex((u) => u.nick === msg.from.nick); + const idx = channel.users.findIndex((u) => u.nick === msg.from?.nick); if (idx > -1) { channel.users.splice(idx, 1); @@ -215,7 +215,7 @@ function updateUserList(channel: ClientChan, msg: SharedMsg) { } case "kick": { - const idx = channel.users.findIndex((u) => u.nick === msg.target.nick); + const idx = channel.users.findIndex((u) => u.nick === msg.target?.nick); if (idx > -1) { channel.users.splice(idx, 1);