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;
|
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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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),
|
||||||
|
|
Loading…
Reference in a new issue