Use libsignal-client for username validation
This commit is contained in:
parent
3ff390e1c4
commit
c0663ed57c
8 changed files with 35 additions and 68 deletions
|
@ -98,11 +98,12 @@ export function ChooseGroupMembersModal({
|
|||
}: PropsType): JSX.Element {
|
||||
const [focusRef] = useRestoreFocus();
|
||||
|
||||
const parsedUsername = getUsernameFromSearch(searchTerm);
|
||||
let username: string | undefined;
|
||||
let isUsernameChecked = false;
|
||||
let isUsernameVisible = false;
|
||||
if (isUsernamesEnabled) {
|
||||
username = getUsernameFromSearch(searchTerm);
|
||||
username = parsedUsername;
|
||||
|
||||
isUsernameChecked = selectedContacts.some(
|
||||
contact => contact.username === username
|
||||
|
@ -114,7 +115,7 @@ export function ChooseGroupMembersModal({
|
|||
}
|
||||
|
||||
let phoneNumber: ParsedE164Type | undefined;
|
||||
if (!username) {
|
||||
if (!parsedUsername) {
|
||||
phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,13 +91,13 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
|||
isShowingRecommendedGroupSizeModal;
|
||||
this.searchTerm = searchTerm;
|
||||
|
||||
if (isUsernamesEnabled) {
|
||||
const username = getUsernameFromSearch(searchTerm);
|
||||
const isVisible = this.candidateContacts.every(
|
||||
contact => contact.username !== username
|
||||
);
|
||||
const username = getUsernameFromSearch(searchTerm);
|
||||
const isUsernameVisible =
|
||||
username !== undefined &&
|
||||
this.candidateContacts.every(contact => contact.username !== username);
|
||||
|
||||
if (isVisible) {
|
||||
if (isUsernamesEnabled) {
|
||||
if (isUsernameVisible) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
|||
}
|
||||
|
||||
const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
|
||||
if (!this.username && phoneNumber) {
|
||||
if (!isUsernameVisible && phoneNumber) {
|
||||
this.isPhoneNumberChecked =
|
||||
phoneNumber.isValid &&
|
||||
selectedContacts.some(contact => contact.e164 === phoneNumber.e164);
|
||||
|
|
|
@ -68,20 +68,20 @@ export class LeftPaneComposeHelper extends LeftPaneHelper<LeftPaneComposePropsTy
|
|||
this.searchTerm = searchTerm;
|
||||
this.uuidFetchState = uuidFetchState;
|
||||
|
||||
const username = getUsernameFromSearch(this.searchTerm);
|
||||
|
||||
if (isUsernamesEnabled) {
|
||||
this.username = getUsernameFromSearch(this.searchTerm);
|
||||
this.username = username;
|
||||
this.isUsernameVisible =
|
||||
isUsernamesEnabled &&
|
||||
Boolean(this.username) &&
|
||||
this.composeContacts.every(
|
||||
contact => contact.username !== this.username
|
||||
);
|
||||
Boolean(username) &&
|
||||
this.composeContacts.every(contact => contact.username !== username);
|
||||
} else {
|
||||
this.isUsernameVisible = false;
|
||||
}
|
||||
|
||||
const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
|
||||
if (!this.username && phoneNumber) {
|
||||
if (!username && phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.isPhoneNumberVisible = this.composeContacts.every(
|
||||
contact => contact.e164 !== phoneNumber.e164
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue