Skip to content

Commit

Permalink
fix chat channels with messages loading
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Nov 21, 2023
1 parent 82ebb55 commit 35ecf67
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/services/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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 = (
Expand Down

0 comments on commit 35ecf67

Please sign in to comment.