New Contact Modal: Fix adding contact with hidden number (#1849)
This commit is contained in:
parent
697b709d89
commit
39ce1790d1
@ -147,7 +147,10 @@ const NewContactModal: FC<OwnProps & StateProps> = ({
|
||||
onChange={handleLastNameChange}
|
||||
/>
|
||||
<p className="NewContactModal__help-text">
|
||||
{renderText(lang('NewContact.Phone.Hidden.Text', renderingUser?.firstName), ['emoji', 'simple_markdown'])}
|
||||
{renderText(
|
||||
lang('NewContact.Phone.Hidden.Text', renderingUser?.firstName || ''),
|
||||
['emoji', 'simple_markdown'],
|
||||
)}
|
||||
</p>
|
||||
<Checkbox
|
||||
checked={shouldSharePhoneNumber}
|
||||
|
||||
@ -194,12 +194,11 @@ async function updateContact(
|
||||
});
|
||||
}
|
||||
|
||||
global = getGlobal();
|
||||
if (result) {
|
||||
getActions().loadChatSettings({ chatId: userId });
|
||||
|
||||
setGlobal(updateUser(
|
||||
global,
|
||||
getGlobal(),
|
||||
user.id,
|
||||
{
|
||||
firstName,
|
||||
@ -208,6 +207,7 @@ async function updateContact(
|
||||
));
|
||||
}
|
||||
|
||||
global = getGlobal();
|
||||
global = updateManagementProgress(global, ManagementProgress.Complete);
|
||||
global = closeNewContactDialog(global);
|
||||
setGlobal(global);
|
||||
|
||||
@ -32,6 +32,10 @@ export function getCountryFromPhoneNumber(phoneCodeList: ApiCountryCode[], input
|
||||
}
|
||||
|
||||
export function formatPhoneNumber(input: string, country?: ApiCountryCode) {
|
||||
if (!input) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let phoneNumber = input.replace(/[^\d]+/g, '');
|
||||
if (country) {
|
||||
phoneNumber = phoneNumber.substr(country.countryCode.length);
|
||||
@ -81,6 +85,10 @@ function getBestPattern(numberWithoutCode: string, patterns?: string[]) {
|
||||
}
|
||||
|
||||
export function formatPhoneNumberWithCode(phoneCodeList: ApiCountryCode[], phoneNumber: string) {
|
||||
if (!phoneNumber) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const numberWithPlus = phoneNumber.startsWith('+') ? phoneNumber : `+${phoneNumber}`;
|
||||
const country = getCountryFromPhoneNumber(phoneCodeList, numberWithPlus);
|
||||
if (!country) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user