getTitle: Return nothing instead of an invalid phone number

This commit is contained in:
Scott Nonnenberg 2023-06-09 10:46:59 -07:00 committed by GitHub
parent 22fb69bbb7
commit 62e648da27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 93 additions and 54 deletions

View file

@ -108,7 +108,7 @@ export function getSystemName(
export function getNumber(
attributes: Pick<ConversationAttributesType, 'e164' | 'type'>
): string {
): string | undefined {
if (!isDirectConversation(attributes)) {
return '';
}
@ -121,7 +121,7 @@ export function getNumber(
return renderNumber(e164);
}
export function renderNumber(e164: string): string {
export function renderNumber(e164: string): string | undefined {
try {
const parsedNumber = window.libphonenumberInstance.parse(e164);
const regionCode = getRegionCodeForNumber(e164);
@ -136,6 +136,6 @@ export function renderNumber(e164: string): string {
window.libphonenumberFormat.INTERNATIONAL
);
} catch (e) {
return e164;
return undefined;
}
}