From 8620a2cd0ad4281dda10877fed5a5020d4bd7b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 15 Jun 2023 15:33:36 -0400 Subject: [PATCH] fix: #11717 prevent crash in messaging --- src/messaging/index.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/messaging/index.js b/src/messaging/index.js index bc7d4ee4db..f5766f3343 100644 --- a/src/messaging/index.js +++ b/src/messaging/index.js @@ -111,7 +111,7 @@ Messaging.getRecentChats = async (callerUid, uid, start, stop) => { teasers: Promise.all(roomIds.map(async roomId => Messaging.getTeaser(uid, roomId))), }); - results.roomData.forEach((room, index) => { + await Promise.all(results.roomData.map(async (room, index) => { if (room) { room.users = results.users[index]; room.groupChat = room.hasOwnProperty('groupChat') ? room.groupChat : room.users.length > 2; @@ -125,12 +125,9 @@ Messaging.getRecentChats = async (callerUid, uid, start, stop) => { }); room.users = room.users.filter(user => user && parseInt(user.uid, 10)); room.lastUser = room.users[0]; - room.usernames = Messaging.generateUsernames(room.users, uid); + room.chatWithMessage = await Messaging.generateChatWithMessage(room.users, uid); } - }); - await Promise.all(results.roomData.map(async (room) => { - room.chatWithMessage = await Messaging.generateChatWithMessage(room.users, uid); })); results.roomData = results.roomData.filter(Boolean);