Fix UI bug with self-add by username in groups

This commit is contained in:
Fedor Indutny 2023-11-08 00:45:33 +01:00 committed by GitHub
parent 41e89554fe
commit ca2b3bacce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 1 deletions

View file

@ -938,6 +938,7 @@ export function ChooseGroupMembersPartialPhoneNumber(): JSX.Element {
isShowingRecommendedGroupSizeModal: false,
isShowingMaximumGroupSizeModal: false,
isUsernamesEnabled: true,
ourUsername: undefined,
searchTerm: '+1(212) 555',
regionCode: 'US',
selectedContacts: [],
@ -960,6 +961,7 @@ export function ChooseGroupMembersValidPhoneNumber(): JSX.Element {
isShowingRecommendedGroupSizeModal: false,
isShowingMaximumGroupSizeModal: false,
isUsernamesEnabled: true,
ourUsername: undefined,
searchTerm: '+1(212) 555 5454',
regionCode: 'US',
selectedContacts: [],
@ -982,6 +984,7 @@ export function ChooseGroupMembersUsername(): JSX.Element {
isShowingRecommendedGroupSizeModal: false,
isShowingMaximumGroupSizeModal: false,
isUsernamesEnabled: true,
ourUsername: undefined,
searchTerm: '@signal',
regionCode: 'US',
selectedContacts: [],

View file

@ -64,6 +64,7 @@ const createProps = (
)}
regionCode="US"
getPreferredBadge={() => undefined}
ourUsername={undefined}
theme={ThemeType.light}
i18n={i18n}
lookupConversationWithoutServiceId={lookupConversationWithoutServiceId}

View file

@ -55,6 +55,7 @@ export type StatePropsType = {
i18n: LocalizerType;
theme: ThemeType;
maxGroupSize: number;
ourUsername: string | undefined;
searchTerm: string;
selectedContacts: ReadonlyArray<ConversationType>;
@ -85,6 +86,7 @@ export function ChooseGroupMembersModal({
i18n,
maxGroupSize,
onClose,
ourUsername,
removeSelectedContact,
searchTerm,
selectedContacts,
@ -110,6 +112,7 @@ export function ChooseGroupMembersModal({
isUsernameVisible =
Boolean(username) &&
username !== ourUsername &&
candidateContacts.every(contact => contact.username !== username);
}

View file

@ -122,6 +122,7 @@ const createProps = (
theme={ThemeType.light}
i18n={i18n}
lookupConversationWithoutServiceId={makeFakeLookupConversationWithoutServiceId()}
ourUsername={undefined}
showUserNotFoundModal={action('showUserNotFoundModal')}
isUsernamesEnabled
/>

View file

@ -35,6 +35,7 @@ export type LeftPaneChooseGroupMembersPropsType = {
isShowingRecommendedGroupSizeModal: boolean;
isShowingMaximumGroupSizeModal: boolean;
isUsernamesEnabled: boolean;
ourUsername: string | undefined;
searchTerm: string;
regionCode: string | undefined;
selectedContacts: Array<ConversationType>;
@ -74,6 +75,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
isUsernamesEnabled,
groupSizeRecommendedLimit,
groupSizeHardLimit,
ourUsername,
searchTerm,
regionCode,
selectedContacts,
@ -94,6 +96,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
const username = getUsernameFromSearch(searchTerm);
const isUsernameVisible =
username !== undefined &&
username !== ourUsername &&
this.candidateContacts.every(contact => contact.username !== username);
if (isUsernamesEnabled) {
@ -109,7 +112,11 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
}
const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
if (!isUsernameVisible && phoneNumber) {
if (
!isUsernameVisible &&
(ourUsername === undefined || username !== ourUsername) &&
phoneNumber
) {
this.isPhoneNumberChecked =
phoneNumber.isValid &&
selectedContacts.some(contact => contact.e164 === phoneNumber.e164);