Process username changes in storage service
This commit is contained in:
parent
71c97e9580
commit
1381e8df5d
8 changed files with 252 additions and 53 deletions
|
@ -36,7 +36,7 @@ export function getTitleNoDefault(
|
|||
|
||||
return (
|
||||
(isShort ? attributes.systemGivenName : undefined) ||
|
||||
attributes.name ||
|
||||
getSystemName(attributes) ||
|
||||
(isShort ? attributes.profileName : undefined) ||
|
||||
getProfileName(attributes) ||
|
||||
getNumber(attributes) ||
|
||||
|
@ -44,6 +44,30 @@ export function getTitleNoDefault(
|
|||
);
|
||||
}
|
||||
|
||||
// Note that the used attributes field should match the ones we listen for
|
||||
// change on in ConversationModel (see `ConversationModel#maybeClearUsername`)
|
||||
export function canHaveUsername(
|
||||
attributes: Pick<
|
||||
ConversationAttributesType,
|
||||
'id' | 'type' | 'name' | 'profileName' | 'profileFamilyName' | 'e164'
|
||||
>,
|
||||
ourConversationId: string | undefined
|
||||
): boolean {
|
||||
if (!isDirectConversation(attributes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ourConversationId === attributes.id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (
|
||||
!getSystemName(attributes) &&
|
||||
!getProfileName(attributes) &&
|
||||
!getNumber(attributes)
|
||||
);
|
||||
}
|
||||
|
||||
export function getProfileName(
|
||||
attributes: Pick<
|
||||
ConversationAttributesType,
|
||||
|
@ -57,6 +81,22 @@ export function getProfileName(
|
|||
return undefined;
|
||||
}
|
||||
|
||||
export function getSystemName(
|
||||
attributes: Pick<
|
||||
ConversationAttributesType,
|
||||
'systemGivenName' | 'systemFamilyName' | 'type'
|
||||
>
|
||||
): string | undefined {
|
||||
if (isDirectConversation(attributes)) {
|
||||
return combineNames(
|
||||
attributes.systemGivenName,
|
||||
attributes.systemFamilyName
|
||||
);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function getNumber(
|
||||
attributes: Pick<ConversationAttributesType, 'e164' | 'type'>
|
||||
): string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue