Fix UI bug with self-add by username in groups
This commit is contained in:
parent
41e89554fe
commit
ca2b3bacce
8 changed files with 21 additions and 1 deletions
|
@ -938,6 +938,7 @@ export function ChooseGroupMembersPartialPhoneNumber(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourUsername: undefined,
|
||||||
searchTerm: '+1(212) 555',
|
searchTerm: '+1(212) 555',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
selectedContacts: [],
|
selectedContacts: [],
|
||||||
|
@ -960,6 +961,7 @@ export function ChooseGroupMembersValidPhoneNumber(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourUsername: undefined,
|
||||||
searchTerm: '+1(212) 555 5454',
|
searchTerm: '+1(212) 555 5454',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
selectedContacts: [],
|
selectedContacts: [],
|
||||||
|
@ -982,6 +984,7 @@ export function ChooseGroupMembersUsername(): JSX.Element {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourUsername: undefined,
|
||||||
searchTerm: '@signal',
|
searchTerm: '@signal',
|
||||||
regionCode: 'US',
|
regionCode: 'US',
|
||||||
selectedContacts: [],
|
selectedContacts: [],
|
||||||
|
|
|
@ -64,6 +64,7 @@ const createProps = (
|
||||||
)}
|
)}
|
||||||
regionCode="US"
|
regionCode="US"
|
||||||
getPreferredBadge={() => undefined}
|
getPreferredBadge={() => undefined}
|
||||||
|
ourUsername={undefined}
|
||||||
theme={ThemeType.light}
|
theme={ThemeType.light}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
lookupConversationWithoutServiceId={lookupConversationWithoutServiceId}
|
lookupConversationWithoutServiceId={lookupConversationWithoutServiceId}
|
||||||
|
|
|
@ -55,6 +55,7 @@ export type StatePropsType = {
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
theme: ThemeType;
|
theme: ThemeType;
|
||||||
maxGroupSize: number;
|
maxGroupSize: number;
|
||||||
|
ourUsername: string | undefined;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
selectedContacts: ReadonlyArray<ConversationType>;
|
selectedContacts: ReadonlyArray<ConversationType>;
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ export function ChooseGroupMembersModal({
|
||||||
i18n,
|
i18n,
|
||||||
maxGroupSize,
|
maxGroupSize,
|
||||||
onClose,
|
onClose,
|
||||||
|
ourUsername,
|
||||||
removeSelectedContact,
|
removeSelectedContact,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
selectedContacts,
|
selectedContacts,
|
||||||
|
@ -110,6 +112,7 @@ export function ChooseGroupMembersModal({
|
||||||
|
|
||||||
isUsernameVisible =
|
isUsernameVisible =
|
||||||
Boolean(username) &&
|
Boolean(username) &&
|
||||||
|
username !== ourUsername &&
|
||||||
candidateContacts.every(contact => contact.username !== username);
|
candidateContacts.every(contact => contact.username !== username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,7 @@ const createProps = (
|
||||||
theme={ThemeType.light}
|
theme={ThemeType.light}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
lookupConversationWithoutServiceId={makeFakeLookupConversationWithoutServiceId()}
|
lookupConversationWithoutServiceId={makeFakeLookupConversationWithoutServiceId()}
|
||||||
|
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;
|
||||||
|
ourUsername: string | undefined;
|
||||||
searchTerm: string;
|
searchTerm: string;
|
||||||
regionCode: string | undefined;
|
regionCode: string | undefined;
|
||||||
selectedContacts: Array<ConversationType>;
|
selectedContacts: Array<ConversationType>;
|
||||||
|
@ -74,6 +75,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
||||||
isUsernamesEnabled,
|
isUsernamesEnabled,
|
||||||
groupSizeRecommendedLimit,
|
groupSizeRecommendedLimit,
|
||||||
groupSizeHardLimit,
|
groupSizeHardLimit,
|
||||||
|
ourUsername,
|
||||||
searchTerm,
|
searchTerm,
|
||||||
regionCode,
|
regionCode,
|
||||||
selectedContacts,
|
selectedContacts,
|
||||||
|
@ -94,6 +96,7 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
||||||
const username = getUsernameFromSearch(searchTerm);
|
const username = getUsernameFromSearch(searchTerm);
|
||||||
const isUsernameVisible =
|
const isUsernameVisible =
|
||||||
username !== undefined &&
|
username !== undefined &&
|
||||||
|
username !== ourUsername &&
|
||||||
this.candidateContacts.every(contact => contact.username !== username);
|
this.candidateContacts.every(contact => contact.username !== username);
|
||||||
|
|
||||||
if (isUsernamesEnabled) {
|
if (isUsernamesEnabled) {
|
||||||
|
@ -109,7 +112,11 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper<LeftPaneCho
|
||||||
}
|
}
|
||||||
|
|
||||||
const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
|
const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode);
|
||||||
if (!isUsernameVisible && phoneNumber) {
|
if (
|
||||||
|
!isUsernameVisible &&
|
||||||
|
(ourUsername === undefined || username !== ourUsername) &&
|
||||||
|
phoneNumber
|
||||||
|
) {
|
||||||
this.isPhoneNumberChecked =
|
this.isPhoneNumberChecked =
|
||||||
phoneNumber.isValid &&
|
phoneNumber.isValid &&
|
||||||
selectedContacts.some(contact => contact.e164 === phoneNumber.e164);
|
selectedContacts.some(contact => contact.e164 === phoneNumber.e164);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { getUsernamesEnabled } from '../selectors/items';
|
||||||
import {
|
import {
|
||||||
getCandidateContactsForNewGroup,
|
getCandidateContactsForNewGroup,
|
||||||
getConversationByIdSelector,
|
getConversationByIdSelector,
|
||||||
|
getMe,
|
||||||
} from '../selectors/conversations';
|
} from '../selectors/conversations';
|
||||||
import { getPreferredBadgeSelector } from '../selectors/badges';
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ const mapStateToProps = (
|
||||||
getPreferredBadge: getPreferredBadgeSelector(state),
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
||||||
i18n: getIntl(state),
|
i18n: getIntl(state),
|
||||||
theme: getTheme(state),
|
theme: getTheme(state),
|
||||||
|
ourUsername: getMe(state).username,
|
||||||
selectedContacts,
|
selectedContacts,
|
||||||
lookupConversationWithoutServiceId,
|
lookupConversationWithoutServiceId,
|
||||||
isUsernamesEnabled: getUsernamesEnabled(state),
|
isUsernamesEnabled: getUsernamesEnabled(state),
|
||||||
|
|
|
@ -58,6 +58,7 @@ import {
|
||||||
getFilteredComposeGroups,
|
getFilteredComposeGroups,
|
||||||
getLeftPaneLists,
|
getLeftPaneLists,
|
||||||
getMaximumGroupSizeModalState,
|
getMaximumGroupSizeModalState,
|
||||||
|
getMe,
|
||||||
getRecommendedGroupSizeModalState,
|
getRecommendedGroupSizeModalState,
|
||||||
getSelectedConversationId,
|
getSelectedConversationId,
|
||||||
getTargetedMessage,
|
getTargetedMessage,
|
||||||
|
@ -179,6 +180,7 @@ const getModeSpecificProps = (
|
||||||
OneTimeModalState.Showing,
|
OneTimeModalState.Showing,
|
||||||
isShowingMaximumGroupSizeModal:
|
isShowingMaximumGroupSizeModal:
|
||||||
getMaximumGroupSizeModalState(state) === OneTimeModalState.Showing,
|
getMaximumGroupSizeModalState(state) === OneTimeModalState.Showing,
|
||||||
|
ourUsername: getMe(state).username,
|
||||||
regionCode: getRegionCode(state),
|
regionCode: getRegionCode(state),
|
||||||
searchTerm: getComposerConversationSearchTerm(state),
|
searchTerm: getComposerConversationSearchTerm(state),
|
||||||
selectedContacts: getComposeSelectedContacts(state),
|
selectedContacts: getComposeSelectedContacts(state),
|
||||||
|
|
|
@ -17,6 +17,7 @@ describe('LeftPaneChooseGroupMembersHelper', () => {
|
||||||
isShowingRecommendedGroupSizeModal: false,
|
isShowingRecommendedGroupSizeModal: false,
|
||||||
isShowingMaximumGroupSizeModal: false,
|
isShowingMaximumGroupSizeModal: false,
|
||||||
isUsernamesEnabled: true,
|
isUsernamesEnabled: true,
|
||||||
|
ourUsername: undefined,
|
||||||
groupSizeRecommendedLimit: 22,
|
groupSizeRecommendedLimit: 22,
|
||||||
groupSizeHardLimit: 33,
|
groupSizeHardLimit: 33,
|
||||||
searchTerm: '',
|
searchTerm: '',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue