Skip to content

Commit

Permalink
Fix group search visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
automated-signal authored and trevor-signal committed Oct 23, 2024
1 parent 3891074 commit 849c6d7
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 28 deletions.
1 change: 0 additions & 1 deletion ts/model-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ export type ConversationAttributesType = {
draftAttachments?: ReadonlyArray<AttachmentDraftType>;
draftBodyRanges?: DraftBodyRanges;
draftTimestamp?: number | null;
hiddenFromConversationSearch?: boolean;
hideStory?: boolean;
inbox_position?: number;
// When contact is removed - it is initially placed into `justNotification`
Expand Down
18 changes: 1 addition & 17 deletions ts/models/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<void> {
if (!isGroupV2(this.attributes)) {
return;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 =
Expand Down
1 change: 0 additions & 1 deletion ts/state/ducks/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ export type ConversationType = ReadonlyDeep<
customColor?: CustomColorType;
customColorId?: string;
discoveredUnregisteredAt?: number;
hiddenFromConversationSearch?: boolean;
hideStory?: boolean;
isArchived?: boolean;
isBlocked?: boolean;
Expand Down
9 changes: 6 additions & 3 deletions ts/state/ducks/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConversationType> = filterAndSortConversations(
visibleConversations,
Expand Down
3 changes: 1 addition & 2 deletions ts/state/selectors/conversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
);

Expand Down
2 changes: 1 addition & 1 deletion ts/util/filterAndSortConversations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions ts/util/getConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 849c6d7

Please sign in to comment.