From 2cd563c7d310665b8c2e7a6d09c2f58b79fecdb2 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Tue, 29 Oct 2024 15:32:41 -0500 Subject: [PATCH] Improve chat search filtering Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com> --- ts/state/ducks/search.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index f0d04d2693..6e6e7c1c77 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -353,10 +353,28 @@ async function queryConversationsAndContacts( const normalizedQuery = removeDiacritics(query); const visibleConversations = allConversations.filter(conversation => { - const { activeAt, removalStage } = conversation; + const { activeAt, removalStage, isBlocked } = conversation; + if (isDirectConversation(conversation)) { - return activeAt != null || removalStage == null; + // if a conversation has messages (i.e. is not "deleted"), always show it + if (activeAt != null) { + return true; + } + + // Don't show if conversation is empty and the contact is blocked + if (isBlocked) { + return false; + } + + // Don't show if conversation is empty and the contact is removed + if (removalStage != null) { + return false; + } + + // Otherwise, show it + return true; } + // We don't show groups in search results that don't have any messages return activeAt != null; });