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}
|
onChange={handleLastNameChange}
|
||||||
/>
|
/>
|
||||||
<p className="NewContactModal__help-text">
|
<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>
|
</p>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={shouldSharePhoneNumber}
|
checked={shouldSharePhoneNumber}
|
||||||
|
|||||||
@ -194,12 +194,11 @@ async function updateContact(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
global = getGlobal();
|
|
||||||
if (result) {
|
if (result) {
|
||||||
getActions().loadChatSettings({ chatId: userId });
|
getActions().loadChatSettings({ chatId: userId });
|
||||||
|
|
||||||
setGlobal(updateUser(
|
setGlobal(updateUser(
|
||||||
global,
|
getGlobal(),
|
||||||
user.id,
|
user.id,
|
||||||
{
|
{
|
||||||
firstName,
|
firstName,
|
||||||
@ -208,6 +207,7 @@ async function updateContact(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
global = getGlobal();
|
||||||
global = updateManagementProgress(global, ManagementProgress.Complete);
|
global = updateManagementProgress(global, ManagementProgress.Complete);
|
||||||
global = closeNewContactDialog(global);
|
global = closeNewContactDialog(global);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|||||||
@ -32,6 +32,10 @@ export function getCountryFromPhoneNumber(phoneCodeList: ApiCountryCode[], input
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatPhoneNumber(input: string, country?: ApiCountryCode) {
|
export function formatPhoneNumber(input: string, country?: ApiCountryCode) {
|
||||||
|
if (!input) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
let phoneNumber = input.replace(/[^\d]+/g, '');
|
let phoneNumber = input.replace(/[^\d]+/g, '');
|
||||||
if (country) {
|
if (country) {
|
||||||
phoneNumber = phoneNumber.substr(country.countryCode.length);
|
phoneNumber = phoneNumber.substr(country.countryCode.length);
|
||||||
@ -81,6 +85,10 @@ function getBestPattern(numberWithoutCode: string, patterns?: string[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatPhoneNumberWithCode(phoneCodeList: ApiCountryCode[], phoneNumber: string) {
|
export function formatPhoneNumberWithCode(phoneCodeList: ApiCountryCode[], phoneNumber: string) {
|
||||||
|
if (!phoneNumber) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
const numberWithPlus = phoneNumber.startsWith('+') ? phoneNumber : `+${phoneNumber}`;
|
const numberWithPlus = phoneNumber.startsWith('+') ? phoneNumber : `+${phoneNumber}`;
|
||||||
const country = getCountryFromPhoneNumber(phoneCodeList, numberWithPlus);
|
const country = getCountryFromPhoneNumber(phoneCodeList, numberWithPlus);
|
||||||
if (!country) {
|
if (!country) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user