On link, ensure group conversations are shown in search

This commit is contained in:
automated-signal 2024-12-10 12:23:02 -06:00 committed by GitHub
parent 291fcffff6
commit 4a775ee8c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 3 deletions

1
ts/model-types.d.ts vendored
View file

@ -379,6 +379,7 @@ export type ConversationAttributesType = {
messageCount?: number; messageCount?: number;
messageCountBeforeMessageRequests?: number | null; messageCountBeforeMessageRequests?: number | null;
messageRequestResponseType?: number; messageRequestResponseType?: number;
messagesDeleted?: boolean;
muteExpiresAt?: number; muteExpiresAt?: number;
dontNotifyForMentionsIfMuted?: boolean; dontNotifyForMentionsIfMuted?: boolean;
sharingPhoneNumber?: boolean; sharingPhoneNumber?: boolean;

View file

@ -407,6 +407,8 @@ export class ConversationModel extends window.Backbone
this.unset('tokens'); this.unset('tokens');
this.on('change:members change:membersV2', this.fetchContacts); this.on('change:members change:membersV2', this.fetchContacts);
this.on('change:active_at', this.onActiveAtChange);
this.typingRefreshTimer = null; this.typingRefreshTimer = null;
this.typingPauseTimer = null; this.typingPauseTimer = null;
@ -4446,6 +4448,13 @@ export class ConversationModel extends window.Backbone
} }
} }
private async onActiveAtChange(): Promise<void> {
if (this.get('active_at') && this.get('messagesDeleted')) {
this.set('messagesDeleted', false);
await DataWriter.updateConversation(this.attributes);
}
}
async refreshGroupLink(): Promise<void> { async refreshGroupLink(): Promise<void> {
if (!isGroupV2(this.attributes)) { if (!isGroupV2(this.attributes)) {
return; return;
@ -5243,6 +5252,7 @@ export class ConversationModel extends window.Backbone
timestamp: null, timestamp: null,
active_at: null, active_at: null,
pendingUniversalTimer: undefined, pendingUniversalTimer: undefined,
messagesDeleted: true,
}); });
await DataWriter.updateConversation(this.attributes); await DataWriter.updateConversation(this.attributes);

View file

@ -317,6 +317,7 @@ export type ConversationType = ReadonlyDeep<
phoneNumber?: string; phoneNumber?: string;
membersCount?: number; membersCount?: number;
hasMessages?: boolean; hasMessages?: boolean;
messagesDeleted?: boolean;
accessControlAddFromInviteLink?: number; accessControlAddFromInviteLink?: number;
accessControlAttributes?: number; accessControlAttributes?: number;
accessControlMembers?: number; accessControlMembers?: number;

View file

@ -566,7 +566,7 @@ async function queryConversationsAndContacts(
const normalizedQuery = removeDiacritics(query); const normalizedQuery = removeDiacritics(query);
const visibleConversations = allConversations.filter(conversation => { const visibleConversations = allConversations.filter(conversation => {
const { activeAt, removalStage, isBlocked } = conversation; const { activeAt, removalStage, isBlocked, messagesDeleted } = conversation;
if (isDirectConversation(conversation)) { if (isDirectConversation(conversation)) {
// if a conversation has messages (i.e. is not "deleted"), always show it // if a conversation has messages (i.e. is not "deleted"), always show it
@ -588,8 +588,8 @@ async function queryConversationsAndContacts(
return true; return true;
} }
// We don't show groups in search results that don't have any messages // We don't show groups that were deleted in search results
return activeAt != null; return !messagesDeleted;
}); });
const searchResults: Array<ConversationType> = filterAndSortConversations( const searchResults: Array<ConversationType> = filterAndSortConversations(

View file

@ -195,6 +195,7 @@ export function getConversation(model: ConversationModel): ConversationType {
markedUnread: attributes.markedUnread, markedUnread: attributes.markedUnread,
membersCount: getMembersCount(attributes), membersCount: getMembersCount(attributes),
memberships: getMemberships(attributes), memberships: getMemberships(attributes),
messagesDeleted: Boolean(attributes.messagesDeleted),
hasMessages: (attributes.messageCount ?? 0) > 0, hasMessages: (attributes.messageCount ?? 0) > 0,
pendingMemberships: getPendingMemberships(attributes), pendingMemberships: getPendingMemberships(attributes),
pendingApprovalMemberships: getPendingApprovalMemberships(attributes), pendingApprovalMemberships: getPendingApprovalMemberships(attributes),