Skip to content

Commit

Permalink
fetch only chat channels with message for the cache middle
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Nov 21, 2023
1 parent f3198ed commit 3deddde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/services/Chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,16 @@ class ChatService {
participantId: string;
startAt?: Timestamp;
endAt?: Timestamp;
onlyWithMessages?: boolean;
}): Promise<ChatChannel[]> => {
const { participantId, startAt, endAt } = options;
const { participantId, startAt, endAt, onlyWithMessages = false } = options;
let query = this.getChatChannelCollection()
.where("participants", "array-contains", participantId)
.orderBy("updatedAt", "desc");

if (onlyWithMessages) {
query = query.where("messageCount", ">", 0);
}
if (startAt) {
query = query.startAt(startAt);
}
Expand Down
1 change: 1 addition & 0 deletions src/shared/hooks/useCases/useInboxItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export const useInboxItems = (
participantId: userId,
startAt,
endAt,
onlyWithMessages: true,
}),
FeedItemFollowsService.getFollowFeedItems({
userId,
Expand Down

0 comments on commit 3deddde

Please sign in to comment.