Group creation/update: Don't allow self-selection via phone number
This commit is contained in:
parent
6579b1a70a
commit
661727c290
8 changed files with 20 additions and 7 deletions
|
@ -938,6 +938,7 @@ export function ChooseGroupMembersPartialPhoneNumber(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourE164: undefined,
|
||||||
ourUsername: undefined,
|
ourUsername: undefined,
|
||||||
searchTerm: '+1(212) 555',
|
searchTerm: '+1(212) 555',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
|
@ -961,6 +962,7 @@ export function ChooseGroupMembersValidPhoneNumber(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourE164: undefined,
|
||||||
ourUsername: undefined,
|
ourUsername: undefined,
|
||||||
searchTerm: '+1(212) 555 5454',
|
searchTerm: '+1(212) 555 5454',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
|
@ -984,6 +986,7 @@ export function ChooseGroupMembersUsername(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourE164: undefined,
|
||||||
ourUsername: undefined,
|
ourUsername: undefined,
|
||||||
searchTerm: '@signal',
|
searchTerm: '@signal',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
|
|
|
@ -64,6 +64,7 @@ const createProps = (
|
||||||
)}
|
)}
|
||||||
regionCode="US"
|
regionCode="US"
|
||||||
getPreferredBadge={() => undefined}
|
getPreferredBadge={() => undefined}
|
||||||
|
ourE164={undefined}
|
||||||
ourUsername={undefined}
|
ourUsername={undefined}
|
||||||
theme={ThemeType.light}
|
theme={ThemeType.light}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
|
|
|
@ -55,6 +55,7 @@ export type StatePropsType = {
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
theme: ThemeType;
|
theme: ThemeType;
|
||||||
maxGroupSize: number;
|
maxGroupSize: number;
|
||||||
|
ourE164: string | undefined;
|
||||||
ourUsername: string | undefined;
|
ourUsername: string | undefined;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
selectedContacts: ReadonlyArray<ConversationType>;
|
selectedContacts: ReadonlyArray<ConversationType>;
|
||||||
|
@ -86,6 +87,7 @@ export function ChooseGroupMembersModal({
|
||||||
i18n,
|
i18n,
|
||||||
maxGroupSize,
|
maxGroupSize,
|
||||||
onClose,
|
onClose,
|
||||||
|
ourE164,
|
||||||
ourUsername,
|
ourUsername,
|
||||||
removeSelectedContact,
|
removeSelectedContact,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
|
@ -129,9 +131,9 @@ export function ChooseGroupMembersModal({
|
||||||
phoneNumber.isValid &&
|
phoneNumber.isValid &&
|
||||||
selectedContacts.some(contact => contact.e164 === e164);
|
selectedContacts.some(contact => contact.e164 === e164);
|
||||||
|
|
||||||
isPhoneNumberVisible = candidateContacts.every(
|
isPhoneNumberVisible =
|
||||||
contact => contact.e164 !== e164
|
e164 !== ourE164 &&
|
||||||
);
|
candidateContacts.every(contact => contact.e164 !== e164);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputRef = useRef<null | HTMLInputElement>(null);
|
const inputRef = useRef<null | HTMLInputElement>(null);
|
||||||
|
|
|
@ -122,6 +122,7 @@ const createProps = (
|
||||||
theme={ThemeType.light}
|
theme={ThemeType.light}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
lookupConversationWithoutServiceId={makeFakeLookupConversationWithoutServiceId()}
|
lookupConversationWithoutServiceId={makeFakeLookupConversationWithoutServiceId()}
|
||||||
|
ourE164={undefined}
|
||||||
ourUsername={undefined}
|
ourUsername={undefined}
|
||||||
showUserNotFoundModal={action('showUserNotFoundModal')}
|
showUserNotFoundModal={action('showUserNotFoundModal')}
|
||||||
isUsernamesEnabled
|
isUsernamesEnabled
|
||||||
|
|
|
@ -35,6 +35,7 @@ export type LeftPaneChooseGroupMembersPropsType = {
|
||||||
isShowingRecommendedGroupSizeModal: boolean;
|
isShowingRecommendedGroupSizeModal: boolean;
|
||||||
isShowingMaximumGroupSizeModal: boolean;
|
isShowingMaximumGroupSizeModal: boolean;
|
||||||
isUsernamesEnabled: boolean;
|
isUsernamesEnabled: boolean;
|
||||||
|
ourE164: string | undefined;
|
||||||
ourUsername: string | undefined;
|
ourUsername: string | undefined;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
regionCode: string | undefined;
|
regionCode: string | undefined;
|
||||||
|
@ -75,6 +76,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
||||||
isUsernamesEnabled,
|
isUsernamesEnabled,
|
||||||
groupSizeRecommendedLimit,
|
groupSizeRecommendedLimit,
|
||||||
groupSizeHardLimit,
|
groupSizeHardLimit,
|
||||||
|
ourE164,
|
||||||
ourUsername,
|
ourUsername,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
regionCode,
|
regionCode,
|
||||||
|
@ -117,13 +119,14 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
||||||
(ourUsername === undefined || username !== ourUsername) &&
|
(ourUsername === undefined || username !== ourUsername) &&
|
||||||
phoneNumber
|
phoneNumber
|
||||||
) {
|
) {
|
||||||
|
const { e164 } = phoneNumber;
|
||||||
this.isPhoneNumberChecked =
|
this.isPhoneNumberChecked =
|
||||||
phoneNumber.isValid &&
|
phoneNumber.isValid &&
|
||||||
selectedContacts.some(contact => contact.e164 === phoneNumber.e164);
|
selectedContacts.some(contact => contact.e164 === e164);
|
||||||
|
|
||||||
const isVisible = this.candidateContacts.every(
|
const isVisible =
|
||||||
contact => contact.e164 !== phoneNumber.e164
|
e164 !== ourE164 &&
|
||||||
);
|
this.candidateContacts.every(contact => contact.e164 !== e164);
|
||||||
if (isVisible) {
|
if (isVisible) {
|
||||||
this.phoneNumber = phoneNumber;
|
this.phoneNumber = phoneNumber;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ const mapStateToProps = (
|
||||||
getPreferredBadge: getPreferredBadgeSelector(state),
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
||||||
i18n: getIntl(state),
|
i18n: getIntl(state),
|
||||||
theme: getTheme(state),
|
theme: getTheme(state),
|
||||||
|
ourE164: getMe(state).e164,
|
||||||
ourUsername: getMe(state).username,
|
ourUsername: getMe(state).username,
|
||||||
selectedContacts,
|
selectedContacts,
|
||||||
lookupConversationWithoutServiceId,
|
lookupConversationWithoutServiceId,
|
||||||
|
|
|
@ -180,6 +180,7 @@ const getModeSpecificProps = (
|
||||||
OneTimeModalState.Showing,
|
OneTimeModalState.Showing,
|
||||||
isShowingMaximumGroupSizeModal:
|
isShowingMaximumGroupSizeModal:
|
||||||
getMaximumGroupSizeModalState(state) === OneTimeModalState.Showing,
|
getMaximumGroupSizeModalState(state) === OneTimeModalState.Showing,
|
||||||
|
ourE164: getMe(state).e164,
|
||||||
ourUsername: getMe(state).username,
|
ourUsername: getMe(state).username,
|
||||||
regionCode: getRegionCode(state),
|
regionCode: getRegionCode(state),
|
||||||
searchTerm: getComposerConversationSearchTerm(state),
|
searchTerm: getComposerConversationSearchTerm(state),
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourE164: undefined,
|
||||||
ourUsername: undefined,
|
ourUsername: undefined,
|
||||||
groupSizeRecommendedLimit: 22,
|
groupSizeRecommendedLimit: 22,
|
||||||
groupSizeHardLimit: 33,
|
groupSizeHardLimit: 33,
|
||||||
|
|
Loading…
Add table
Reference in a new issue