Smarter incoming message handling for filter by unread

This commit is contained in:
yash-signal
2024-11-22 13:23:04 -06:00
committed by GitHub
parent a1a64dd25a
commit f36528e85a
3 changed files with 185 additions and 17 deletions

View File

@@ -165,12 +165,17 @@ export function filterAndSortConversations(
conversations: ReadonlyArray<ConversationType>,
searchTerm: string,
regionCode: string | undefined,
filterByUnread: boolean = false
filterByUnread: boolean = false,
conversationToInject?: ConversationType
): Array<ConversationType> {
const filteredConversations = filterByUnread
let filteredConversations = filterByUnread
? filterConversationsByUnread(conversations, true)
: conversations;
if (conversationToInject) {
filteredConversations = [...filteredConversations, conversationToInject];
}
if (searchTerm.length) {
const now = Date.now();
const withoutUnknownAndFiltered = filteredConversations.filter(