Convert libphonenumber utilities to TypeScript, removing unused ones

This commit is contained in:
Evan Hahn 2022-06-01 17:48:16 +00:00 committed by GitHub
parent 9c8fd2a714
commit ab9a50357b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 340 deletions

View file

@ -19,6 +19,10 @@ import type {
} from '../model-types.d';
import { getInitials } from '../util/getInitials';
import { normalizeUuid } from '../util/normalizeUuid';
import {
getRegionCodeForNumber,
parseNumber,
} from '../util/libphonenumberUtil';
import { clearTimeoutIfNecessary } from '../util/clearTimeoutIfNecessary';
import type { AttachmentType } from '../types/Attachment';
import { isGIF } from '../types/Attachment';
@ -3406,7 +3410,7 @@ export class ConversationModel extends window.Backbone
if (!regionCode) {
throw new Error('No region code');
}
const number = window.libphonenumber.util.parseNumber(
const number = parseNumber(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.get('e164')!,
regionCode
@ -5017,8 +5021,7 @@ export class ConversationModel extends window.Backbone
const number = this.get('e164')!;
try {
const parsedNumber = window.libphonenumber.parse(number);
const regionCode =
window.libphonenumber.getRegionCodeForNumber(parsedNumber);
const regionCode = getRegionCodeForNumber(parsedNumber);
if (regionCode === window.storage.get('regionCode')) {
return window.libphonenumber.format(
parsedNumber,