On link, ensure group conversations are shown in search
This commit is contained in:
parent
291fcffff6
commit
4a775ee8c1
5 changed files with 16 additions and 3 deletions
1
ts/model-types.d.ts
vendored
1
ts/model-types.d.ts
vendored
|
@ -379,6 +379,7 @@ export type ConversationAttributesType = {
|
|||
messageCount?: number;
|
||||
messageCountBeforeMessageRequests?: number | null;
|
||||
messageRequestResponseType?: number;
|
||||
messagesDeleted?: boolean;
|
||||
muteExpiresAt?: number;
|
||||
dontNotifyForMentionsIfMuted?: boolean;
|
||||
sharingPhoneNumber?: boolean;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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> {
|
||||
if (!isGroupV2(this.attributes)) {
|
||||
return;
|
||||
|
@ -5243,6 +5252,7 @@ export class ConversationModel extends window.Backbone
|
|||
timestamp: null,
|
||||
active_at: null,
|
||||
pendingUniversalTimer: undefined,
|
||||
messagesDeleted: true,
|
||||
});
|
||||
await DataWriter.updateConversation(this.attributes);
|
||||
|
||||
|
|
|
@ -317,6 +317,7 @@ export type ConversationType = ReadonlyDeep<
|
|||
phoneNumber?: string;
|
||||
membersCount?: number;
|
||||
hasMessages?: boolean;
|
||||
messagesDeleted?: boolean;
|
||||
accessControlAddFromInviteLink?: number;
|
||||
accessControlAttributes?: number;
|
||||
accessControlMembers?: number;
|
||||
|
|
|
@ -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<ConversationType> = filterAndSortConversations(
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue