mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-28 04:13:18 +01:00
Display nicely formatted phone numbers
In conversation headers and as titles for contacts with no name. Updated tests accordingly. // FREEBIE
This commit is contained in:
@@ -223,18 +223,28 @@
|
||||
|
||||
getTitle: function() {
|
||||
if (this.isPrivate()) {
|
||||
return this.get('name') || this.id;
|
||||
return this.get('name') || this.getNumber();
|
||||
} else {
|
||||
return this.get('name') || 'Unknown group';
|
||||
}
|
||||
},
|
||||
|
||||
getNumber: function() {
|
||||
if (this.isPrivate()) {
|
||||
return this.id;
|
||||
} else {
|
||||
if (!this.isPrivate()) {
|
||||
return '';
|
||||
}
|
||||
var number = this.id;
|
||||
try {
|
||||
var parsedNumber = libphonenumber.parse(number);
|
||||
var regionCode = libphonenumber.getRegionCodeForNumber(parsedNumber);
|
||||
if (regionCode === storage.get('regionCode')) {
|
||||
return libphonenumber.format(parsedNumber, libphonenumber.PhoneNumberFormat.NATIONAL);
|
||||
} else {
|
||||
return libphonenumber.format(parsedNumber, libphonenumber.PhoneNumberFormat.INTERNATIONAL);
|
||||
}
|
||||
} catch (e) {
|
||||
return number;
|
||||
}
|
||||
},
|
||||
|
||||
isPrivate: function() {
|
||||
|
||||
Reference in New Issue
Block a user