From 35946ef53ccdcc6257dd9b6d3a78a85a3d4d09b5 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:49:22 -0400 Subject: [PATCH] Fix group search visibility --- ts/model-types.d.ts | 1 - ts/models/conversations.ts | 18 +----------------- ts/state/ducks/conversations.ts | 1 - ts/state/ducks/search.ts | 9 ++++++--- ts/state/selectors/conversations.ts | 3 +-- ts/util/filterAndSortConversations.ts | 2 +- ts/util/getConversation.ts | 3 --- 7 files changed, 9 insertions(+), 28 deletions(-) diff --git a/ts/model-types.d.ts b/ts/model-types.d.ts index cda9fa6bf43a..f0d9cd02abb0 100644 --- a/ts/model-types.d.ts +++ b/ts/model-types.d.ts @@ -354,7 +354,6 @@ export type ConversationAttributesType = { draftAttachments?: ReadonlyArray; draftBodyRanges?: DraftBodyRanges; draftTimestamp?: number | null; - hiddenFromConversationSearch?: boolean; hideStory?: boolean; inbox_position?: number; // When contact is removed - it is initially placed into `justNotification` diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 62a238820f6f..bfefc8ce8a04 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -407,8 +407,6 @@ export class ConversationModel extends window.Backbone this.unset('tokens'); this.on('change:members change:membersV2', this.fetchContacts); - this.on('change:active_at', this.onActiveAtChange); - this.typingRefreshTimer = null; this.typingPauseTimer = null; @@ -4418,12 +4416,6 @@ export class ConversationModel extends window.Backbone } } - private onActiveAtChange(): void { - if (this.get('active_at') && this.get('hiddenFromConversationSearch')) { - this.set('hiddenFromConversationSearch', false); - } - } - async refreshGroupLink(): Promise { if (!isGroupV2(this.attributes)) { return; @@ -4854,12 +4846,7 @@ export class ConversationModel extends window.Backbone ourAci ); const sharedGroups = ourGroups - .filter( - c => - c.hasMember(ourAci) && - c.hasMember(theirAci) && - !c.attributes.hiddenFromConversationSearch - ) + .filter(c => c.hasMember(ourAci) && c.hasMember(theirAci)) .sort( (left, right) => (right.get('timestamp') || 0) - (left.get('timestamp') || 0) @@ -5222,9 +5209,6 @@ export class ConversationModel extends window.Backbone active_at: null, pendingUniversalTimer: undefined, }); - if (isGroup(this.attributes)) { - this.set('hiddenFromConversationSearch', true); - } await DataWriter.updateConversation(this.attributes); const ourConversation = diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 34509d7a2d47..cb6018fb7811 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -296,7 +296,6 @@ export type ConversationType = ReadonlyDeep< customColor?: CustomColorType; customColorId?: string; discoveredUnregisteredAt?: number; - hiddenFromConversationSearch?: boolean; hideStory?: boolean; isArchived?: boolean; isBlocked?: boolean; diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index bfa59669b5a4..f0d04d269340 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -352,11 +352,14 @@ async function queryConversationsAndContacts( const normalizedQuery = removeDiacritics(query); - const visibleConversations = allConversations.filter( - ({ activeAt, removalStage }) => { + const visibleConversations = allConversations.filter(conversation => { + const { activeAt, removalStage } = conversation; + if (isDirectConversation(conversation)) { return activeAt != null || removalStage == null; } - ); + // We don't show groups in search results that don't have any messages + return activeAt != null; + }); const searchResults: Array = filterAndSortConversations( visibleConversations, diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 02af48ebce3c..03367eeaea78 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -589,8 +589,7 @@ export const getAllComposableConversations = createSelector( // All conversation should have a title except in weird cases where // they don't, in that case we don't want to show these for Forwarding. conversation.titleNoDefault && - hasDisplayInfo(conversation) && - !conversation.hiddenFromConversationSearch + hasDisplayInfo(conversation) ) ); diff --git a/ts/util/filterAndSortConversations.ts b/ts/util/filterAndSortConversations.ts index 2890b94d83fc..d85abd7c82e8 100644 --- a/ts/util/filterAndSortConversations.ts +++ b/ts/util/filterAndSortConversations.ts @@ -165,7 +165,7 @@ export function filterAndSortConversations( const withoutUnknown = conversations.filter(item => item.titleNoDefault); return searchConversations(withoutUnknown, searchTerm, regionCode) - .filter(({ item }) => !item.hiddenFromConversationSearch) + .slice() .sort((a, b) => { const { activeAt: aActiveAt = 0, left: aLeft = false } = a.item; const { activeAt: bActiveAt = 0, left: bLeft = false } = b.item; diff --git a/ts/util/getConversation.ts b/ts/util/getConversation.ts index b05d274dfa47..f331458b3775 100644 --- a/ts/util/getConversation.ts +++ b/ts/util/getConversation.ts @@ -175,9 +175,6 @@ export function getConversation(model: ConversationModel): ConversationType { groupVersion, groupId: attributes.groupId, groupLink: buildGroupLink(attributes), - hiddenFromConversationSearch: Boolean( - attributes.hiddenFromConversationSearch - ), hideStory: Boolean(attributes.hideStory), inboxPosition, isArchived: attributes.isArchived,