From 9722ef56725e8f2e8e72c78c006eefca832a6de1 Mon Sep 17 00:00:00 2001 From: trevor-signal <131492920+trevor-signal@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:04:00 -0500 Subject: [PATCH] On link, ensure group conversations are shown in search --- ts/model-types.d.ts | 1 + ts/models/conversations.ts | 10 ++++++++++ ts/state/ducks/conversations.ts | 1 + ts/state/ducks/search.ts | 6 +++--- ts/util/getConversation.ts | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ts/model-types.d.ts b/ts/model-types.d.ts index ade5253d8c7..f3f181e4ebe 100644 --- a/ts/model-types.d.ts +++ b/ts/model-types.d.ts @@ -379,6 +379,7 @@ export type ConversationAttributesType = { messageCount?: number; messageCountBeforeMessageRequests?: number | null; messageRequestResponseType?: number; + messagesDeleted?: boolean; muteExpiresAt?: number; dontNotifyForMentionsIfMuted?: boolean; sharingPhoneNumber?: boolean; diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 98da25c5598..0c866b6acea 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -407,6 +407,8 @@ 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; @@ -4455,6 +4457,13 @@ export class ConversationModel extends window.Backbone } } + private async onActiveAtChange(): Promise { + if (this.get('active_at') && this.get('messagesDeleted')) { + this.set('messagesDeleted', false); + await DataWriter.updateConversation(this.attributes); + } + } + async refreshGroupLink(): Promise { if (!isGroupV2(this.attributes)) { return; @@ -5228,6 +5237,7 @@ export class ConversationModel extends window.Backbone timestamp: null, active_at: null, pendingUniversalTimer: undefined, + messagesDeleted: true, }); await DataWriter.updateConversation(this.attributes); diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index b42ea4dd90a..b2cb2cbf742 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -320,6 +320,7 @@ export type ConversationType = ReadonlyDeep< phoneNumber?: string; membersCount?: number; hasMessages?: boolean; + messagesDeleted?: boolean; accessControlAddFromInviteLink?: number; accessControlAttributes?: number; accessControlMembers?: number; diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index 2c7d1566e6e..ed2f17b1603 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -566,7 +566,7 @@ async function queryConversationsAndContacts( const normalizedQuery = removeDiacritics(query); const visibleConversations = allConversations.filter(conversation => { - const { activeAt, removalStage, isBlocked } = conversation; + const { activeAt, removalStage, isBlocked, messagesDeleted } = conversation; if (isDirectConversation(conversation)) { // if a conversation has messages (i.e. is not "deleted"), always show it @@ -588,8 +588,8 @@ async function queryConversationsAndContacts( return true; } - // We don't show groups in search results that don't have any messages - return activeAt != null; + // We don't show groups that were deleted in search results + return !messagesDeleted; }); const searchResults: Array = filterAndSortConversations( diff --git a/ts/util/getConversation.ts b/ts/util/getConversation.ts index f331458b377..4bbd09a631b 100644 --- a/ts/util/getConversation.ts +++ b/ts/util/getConversation.ts @@ -195,6 +195,7 @@ export function getConversation(model: ConversationModel): ConversationType { markedUnread: attributes.markedUnread, membersCount: getMembersCount(attributes), memberships: getMemberships(attributes), + messagesDeleted: Boolean(attributes.messagesDeleted), hasMessages: (attributes.messageCount ?? 0) > 0, pendingMemberships: getPendingMemberships(attributes), pendingApprovalMemberships: getPendingApprovalMemberships(attributes),