Eliminate unknown groups and contacts from search results
This commit is contained in:
parent
a921f267f5
commit
5ed5483dd7
|
@ -1912,6 +1912,7 @@ export class ConversationModel extends window.Backbone
|
||||||
sortedGroupMembers,
|
sortedGroupMembers,
|
||||||
timestamp,
|
timestamp,
|
||||||
title: this.getTitle(),
|
title: this.getTitle(),
|
||||||
|
titleNoDefault: this.getTitleNoDefault(),
|
||||||
typingContactId: typingMostRecent?.senderId,
|
typingContactId: typingMostRecent?.senderId,
|
||||||
searchableTitle: isMe(this.attributes)
|
searchableTitle: isMe(this.attributes)
|
||||||
? window.i18n('noteToSelf')
|
? window.i18n('noteToSelf')
|
||||||
|
@ -4950,7 +4951,21 @@ export class ConversationModel extends window.Backbone
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitle({ isShort = false }: { isShort?: boolean } = {}): string {
|
getTitle(options?: { isShort?: boolean }): string {
|
||||||
|
const title = this.getTitleNoDefault(options);
|
||||||
|
if (title) {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDirectConversation(this.attributes)) {
|
||||||
|
return window.i18n('unknownContact');
|
||||||
|
}
|
||||||
|
return window.i18n('unknownGroup');
|
||||||
|
}
|
||||||
|
|
||||||
|
getTitleNoDefault({ isShort = false }: { isShort?: boolean } = {}):
|
||||||
|
| string
|
||||||
|
| undefined {
|
||||||
if (isDirectConversation(this.attributes)) {
|
if (isDirectConversation(this.attributes)) {
|
||||||
const username = this.get('username');
|
const username = this.get('username');
|
||||||
|
|
||||||
|
@ -4959,11 +4974,10 @@ export class ConversationModel extends window.Backbone
|
||||||
(isShort ? this.get('profileName') : undefined) ||
|
(isShort ? this.get('profileName') : undefined) ||
|
||||||
this.getProfileName() ||
|
this.getProfileName() ||
|
||||||
this.getNumber() ||
|
this.getNumber() ||
|
||||||
(username && window.i18n('at-username', { username })) ||
|
(username && window.i18n('at-username', { username }))
|
||||||
window.i18n('unknownContact')
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.get('name') || window.i18n('unknownGroup');
|
return this.get('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
getProfileName(): string | undefined {
|
getProfileName(): string | undefined {
|
||||||
|
|
|
@ -185,6 +185,7 @@ export type ConversationType = {
|
||||||
// This is used by the CompositionInput for @mentions
|
// This is used by the CompositionInput for @mentions
|
||||||
sortedGroupMembers?: Array<ConversationType>;
|
sortedGroupMembers?: Array<ConversationType>;
|
||||||
title: string;
|
title: string;
|
||||||
|
titleNoDefault?: string;
|
||||||
searchableTitle?: string;
|
searchableTitle?: string;
|
||||||
unreadCount?: number;
|
unreadCount?: number;
|
||||||
isSelected?: boolean;
|
isSelected?: boolean;
|
||||||
|
|
|
@ -472,7 +472,7 @@ export const getAllComposableConversations = createSelector(
|
||||||
!isConversationUnregistered(conversation) &&
|
!isConversationUnregistered(conversation) &&
|
||||||
// All conversation should have a title except in weird cases where
|
// 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.
|
// they don't, in that case we don't want to show these for Forwarding.
|
||||||
conversation.title &&
|
conversation.titleNoDefault &&
|
||||||
hasDisplayInfo(conversation)
|
hasDisplayInfo(conversation)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,6 +36,7 @@ export function getDefaultConversation(
|
||||||
markedUnread: Boolean(overrideProps.markedUnread),
|
markedUnread: Boolean(overrideProps.markedUnread),
|
||||||
sharedGroupNames: [],
|
sharedGroupNames: [],
|
||||||
title: `${firstName} ${lastName}`,
|
title: `${firstName} ${lastName}`,
|
||||||
|
titleNoDefault: `${firstName} ${lastName}`,
|
||||||
type: 'direct' as const,
|
type: 'direct' as const,
|
||||||
uuid: UUID.generate().toString(),
|
uuid: UUID.generate().toString(),
|
||||||
...overrideProps,
|
...overrideProps,
|
||||||
|
|
|
@ -65,21 +65,26 @@ describe('both/state/selectors/conversations', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeConversation(id: string): ConversationType {
|
function makeConversation(id: string): ConversationType {
|
||||||
|
const title = `${id} title`;
|
||||||
return getDefaultConversation({
|
return getDefaultConversation({
|
||||||
id,
|
id,
|
||||||
searchableTitle: `${id} title`,
|
searchableTitle: title,
|
||||||
title: `${id} title`,
|
title,
|
||||||
|
titleNoDefault: title,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeConversationWithUuid(
|
function makeConversationWithUuid(
|
||||||
id: string
|
id: string
|
||||||
): ConversationType & { uuid: UUIDStringType } {
|
): ConversationType & { uuid: UUIDStringType } {
|
||||||
|
const title = `${id} title`;
|
||||||
|
|
||||||
return getDefaultConversationWithUuid(
|
return getDefaultConversationWithUuid(
|
||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
searchableTitle: `${id} title`,
|
searchableTitle: title,
|
||||||
title: `${id} title`,
|
title,
|
||||||
|
titleNoDefault: title,
|
||||||
},
|
},
|
||||||
UUID.fromPrefix(id).toString()
|
UUID.fromPrefix(id).toString()
|
||||||
);
|
);
|
||||||
|
@ -555,7 +560,8 @@ describe('both/state/selectors/conversations', () => {
|
||||||
...makeConversation('convo-6'),
|
...makeConversation('convo-6'),
|
||||||
profileSharing: true,
|
profileSharing: true,
|
||||||
name: 'Should Be Dropped (no title)',
|
name: 'Should Be Dropped (no title)',
|
||||||
title: null,
|
title: 'Unknown group',
|
||||||
|
titleNoDefault: undefined,
|
||||||
},
|
},
|
||||||
'convo-7': {
|
'convo-7': {
|
||||||
...makeConversation('convo-7'),
|
...makeConversation('convo-7'),
|
||||||
|
|
|
@ -118,7 +118,9 @@ export function filterAndSortConversationsByRecent(
|
||||||
if (searchTerm.length) {
|
if (searchTerm.length) {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
||||||
return searchConversations(conversations, searchTerm, regionCode)
|
const withoutUnknown = conversations.filter(item => item.titleNoDefault);
|
||||||
|
|
||||||
|
return searchConversations(withoutUnknown, searchTerm, regionCode)
|
||||||
.slice()
|
.slice()
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
const { activeAt: aActiveAt = 0, left: aLeft = false } = a.item;
|
const { activeAt: aActiveAt = 0, left: aLeft = false } = a.item;
|
||||||
|
|
Loading…
Reference in New Issue