From 35ecf67e5351ef7fa3a1b5836b762daa5b63679f Mon Sep 17 00:00:00 2001 From: Andrey Mikhadyuk Date: Tue, 21 Nov 2023 14:54:34 +0300 Subject: [PATCH] fix chat channels with messages loading --- src/services/Chat.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/Chat.ts b/src/services/Chat.ts index 465c4b693f..581fad5d3a 100644 --- a/src/services/Chat.ts +++ b/src/services/Chat.ts @@ -245,9 +245,6 @@ class ChatService { .where("participants", "array-contains", participantId) .orderBy("updatedAt", "desc"); - if (onlyWithMessages) { - query = query.where("messageCount", ">", 0); - } if (startAt) { query = query.startAt(startAt); } @@ -256,8 +253,13 @@ class ChatService { } const snapshot = await query.get(); + const chatChannels = snapshot.docs.map((doc) => doc.data()); + + if (!onlyWithMessages) { + return chatChannels; + } - return snapshot.docs.map((doc) => doc.data()); + return chatChannels.filter((chatChannel) => chatChannel.messageCount > 0); }; public subscribeToNewUpdatedChatChannels = (