From d19cd00b373e68cd29d26c9ce9b31b732cbb9809 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:17:36 -0600 Subject: [PATCH] Enable usernames Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> --- ts/RemoteConfig.ts | 2 - ts/components/LeftPane.stories.tsx | 50 --- ts/components/Preferences.stories.tsx | 3 - ts/components/Preferences.tsx | 28 +- ts/components/ProfileEditor.stories.tsx | 17 +- ts/components/ProfileEditor.tsx | 317 +++++++++--------- .../AddGroupMembersModal.stories.tsx | 1 - .../ChooseGroupMembersModal.tsx | 26 +- .../ConversationDetails.stories.tsx | 1 - .../LeftPaneChooseGroupMembersHelper.tsx | 18 +- .../leftPane/LeftPaneComposeHelper.tsx | 15 +- ts/main/settingsChannel.ts | 1 - ts/state/selectors/items.ts | 6 - ts/state/smart/ChooseGroupMembersModal.tsx | 2 - ts/state/smart/LeftPane.tsx | 3 - ts/state/smart/ProfileEditorModal.tsx | 3 - ts/state/smart/ToastManager.tsx | 7 +- ts/test-both/RemoteConfig_test.ts | 12 +- ts/test-both/state/selectors/items_test.ts | 33 -- .../LeftPaneChooseGroupMembersHelper_test.ts | 4 - .../leftPane/LeftPaneComposeHelper_test.ts | 64 ---- ts/util/createIPCEvents.ts | 3 - ts/util/isPhoneNumberSharingEnabled.ts | 11 - ts/windows/preload.ts | 1 - ts/windows/settings/app.tsx | 2 - ts/windows/settings/preload.ts | 4 - 26 files changed, 196 insertions(+), 438 deletions(-) delete mode 100644 ts/util/isPhoneNumberSharingEnabled.ts diff --git a/ts/RemoteConfig.ts b/ts/RemoteConfig.ts index 4729ebff45..728b383ef1 100644 --- a/ts/RemoteConfig.ts +++ b/ts/RemoteConfig.ts @@ -22,11 +22,9 @@ export type ConfigKeyType = | 'desktop.internalUser' | 'desktop.mediaQuality.levels' | 'desktop.messageCleanup' - | 'desktop.pnp' | 'desktop.retryRespondMaxAge' | 'desktop.senderKey.retry' | 'desktop.senderKeyMaxAge' - | 'desktop.usernames' | 'global.attachments.maxBytes' | 'global.attachments.maxReceiveBytes' | 'global.calling.maxGroupCallRingSize' diff --git a/ts/components/LeftPane.stories.tsx b/ts/components/LeftPane.stories.tsx index f5c1ea3fbb..c88d91455b 100644 --- a/ts/components/LeftPane.stories.tsx +++ b/ts/components/LeftPane.stories.tsx @@ -653,7 +653,6 @@ export function ComposeNoResults(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: [], composeGroups: [], - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: '', @@ -671,7 +670,6 @@ export function ComposeSomeContactsNoSearchTerm(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: defaultConversations, composeGroups: [], - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: '', @@ -689,7 +687,6 @@ export function ComposeSomeContactsWithASearchTerm(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: defaultConversations, composeGroups: [], - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: 'ar', @@ -707,7 +704,6 @@ export function ComposeSomeGroupsNoSearchTerm(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: [], composeGroups: defaultGroups, - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: '', @@ -725,7 +721,6 @@ export function ComposeSomeGroupsWithSearchTerm(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: [], composeGroups: defaultGroups, - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: 'ar', @@ -743,7 +738,6 @@ export function ComposeSearchIsValidUsername(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: [], composeGroups: [], - isUsernamesEnabled: true, uuidFetchState: {}, regionCode: 'US', searchTerm: 'someone', @@ -761,7 +755,6 @@ export function ComposeSearchIsValidUsernameFetchingUsername(): JSX.Element { mode: LeftPaneMode.Compose, composeContacts: [], composeGroups: [], - isUsernamesEnabled: true, uuidFetchState: { 'username:someone': true, }, @@ -773,42 +766,6 @@ export function ComposeSearchIsValidUsernameFetchingUsername(): JSX.Element { ); } -export function ComposeSearchIsValidUsernameButFlagIsNotEnabled(): JSX.Element { - return ( - - ); -} - -export function ComposeSearchIsPartialPhoneNumber(): JSX.Element { - return ( - - ); -} - export function ComposeSearchIsValidPhoneNumber(): JSX.Element { return ( - {isPhoneNumberSharingSupported ? ( - - ) : null} + ; username?: string; initialEditState?: EditState; @@ -152,7 +151,6 @@ export function ProfileEditor({ hasCompletedUsernameLinkOnboarding, i18n, initialEditState = EditState.None, - isUsernameFlagEnabled, markCompletedUsernameLinkOnboarding, onEditStateChanged, onProfileChanged, @@ -548,168 +546,165 @@ export function ProfileEditor({ /> ); } else if (editState === EditState.None) { - let maybeUsernameRows: JSX.Element | undefined; - if (isUsernameFlagEnabled) { - let actions: JSX.Element | undefined; - let alwaysShowActions = false; + let actions: JSX.Element | undefined; + let alwaysShowActions = false; - if (usernameEditState === UsernameEditState.Deleting) { - actions = ( - - ); - } else { - const menuOptions = [ - { - group: 'copy', - icon: 'ProfileEditor__username-menu__copy-icon', - label: i18n('icu:ProfileEditor--username--copy'), - onClick: () => { - assertDev( - username !== undefined, - 'Should not be visible without username' - ); - void window.navigator.clipboard.writeText(username); - showToast({ toastType: ToastType.CopiedUsername }); - }, - }, - { - // Different group to display a divider above it - group: 'delete', - - icon: 'ProfileEditor__username-menu__trash-icon', - label: i18n('icu:ProfileEditor--username--delete'), - onClick: () => { - setUsernameEditState(UsernameEditState.ConfirmingDelete); - }, - }, - ]; - - if (usernameCorrupted) { - actions = ( - - ); - alwaysShowActions = true; - } else if (username) { - actions = ( - - ); - } - } - - let maybeUsernameLinkRow: JSX.Element | undefined; - if (username && !usernameCorrupted) { - let linkActions: JSX.Element | undefined; - - if (usernameLinkCorrupted) { - linkActions = ( - - ); - } - - maybeUsernameLinkRow = ( - - } - label={i18n('icu:ProfileEditor__username-link')} - onClick={() => { - if (usernameLinkCorrupted) { - setIsResettingUsernameLink(true); - return; - } - - setEditState(EditState.UsernameLink); - }} - alwaysShowActions - actions={linkActions} - /> - ); - - if (!hasCompletedUsernameLinkOnboarding) { - const tooltip = ( -
-
- -
-

- {i18n('icu:ProfileEditor__username-link__tooltip__title')} -

-

{i18n('icu:ProfileEditor__username-link__tooltip__body')}

-
- -
- ); - maybeUsernameLinkRow = ( - - {maybeUsernameLinkRow} - - ); - } - } - - maybeUsernameRows = ( - <> -
- - } - label={ - (!usernameCorrupted && username) || - i18n('icu:ProfileEditor--username') - } - onClick={() => { - if (usernameCorrupted) { - setIsResettingUsername(true); - return; - } - - openUsernameReservationModal(); - setEditState(EditState.Username); - }} - alwaysShowActions={alwaysShowActions} - actions={actions} - /> - {maybeUsernameLinkRow} -
- {username - ? i18n('icu:ProfileEditor--info--pnp') - : i18n('icu:ProfileEditor--info--pnp--no-username')} -
- + if (usernameEditState === UsernameEditState.Deleting) { + actions = ( + ); + } else { + const menuOptions = [ + { + group: 'copy', + icon: 'ProfileEditor__username-menu__copy-icon', + label: i18n('icu:ProfileEditor--username--copy'), + onClick: () => { + assertDev( + username !== undefined, + 'Should not be visible without username' + ); + void window.navigator.clipboard.writeText(username); + showToast({ toastType: ToastType.CopiedUsername }); + }, + }, + { + // Different group to display a divider above it + group: 'delete', + + icon: 'ProfileEditor__username-menu__trash-icon', + label: i18n('icu:ProfileEditor--username--delete'), + onClick: () => { + setUsernameEditState(UsernameEditState.ConfirmingDelete); + }, + }, + ]; + + if (usernameCorrupted) { + actions = ( + + ); + alwaysShowActions = true; + } else if (username) { + actions = ( + + ); + } } + let maybeUsernameLinkRow: JSX.Element | undefined; + if (username && !usernameCorrupted) { + let linkActions: JSX.Element | undefined; + + if (usernameLinkCorrupted) { + linkActions = ( + + ); + } + + maybeUsernameLinkRow = ( + + } + label={i18n('icu:ProfileEditor__username-link')} + onClick={() => { + if (usernameLinkCorrupted) { + setIsResettingUsernameLink(true); + return; + } + + setEditState(EditState.UsernameLink); + }} + alwaysShowActions + actions={linkActions} + /> + ); + + if (!hasCompletedUsernameLinkOnboarding) { + const tooltip = ( +
+
+ +
+

+ {i18n('icu:ProfileEditor__username-link__tooltip__title')} +

+

{i18n('icu:ProfileEditor__username-link__tooltip__body')}

+
+ +
+ ); + maybeUsernameLinkRow = ( + + {maybeUsernameLinkRow} + + ); + } + } + + const usernameRows = ( + <> +
+ + } + label={ + (!usernameCorrupted && username) || + i18n('icu:ProfileEditor--username') + } + onClick={() => { + if (usernameCorrupted) { + setIsResettingUsername(true); + return; + } + + openUsernameReservationModal(); + setEditState(EditState.Username); + }} + alwaysShowActions={alwaysShowActions} + actions={actions} + /> + {maybeUsernameLinkRow} +
+ {username + ? i18n('icu:ProfileEditor--info--pnp') + : i18n('icu:ProfileEditor--info--pnp--no-username')} +
+ + ); + content = ( <> {i18n('icu:ProfileEditor--info--general')}
- {maybeUsernameRows} + {usernameRows} ); } else { diff --git a/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx b/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx index 55ae5f9ff8..08a0b9a0cf 100644 --- a/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx +++ b/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx @@ -70,7 +70,6 @@ const createProps = ( i18n={i18n} lookupConversationWithoutServiceId={lookupConversationWithoutServiceId} showUserNotFoundModal={action('showUserNotFoundModal')} - isUsernamesEnabled /> ); }, diff --git a/ts/components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal.tsx b/ts/components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal.tsx index f36a9e1d17..88c01f3c44 100644 --- a/ts/components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal.tsx +++ b/ts/components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal.tsx @@ -65,7 +65,6 @@ export type StatePropsType = { removeSelectedContact: (_: string) => void; setSearchTerm: (_: string) => void; toggleSelectedContact: (conversationId: string) => void; - isUsernamesEnabled: boolean; } & Pick< LookupConversationWithoutServiceIdActionsType, 'lookupConversationWithoutServiceId' @@ -97,29 +96,22 @@ export function ChooseGroupMembersModal({ toggleSelectedContact, lookupConversationWithoutServiceId, showUserNotFoundModal, - isUsernamesEnabled, }: PropsType): JSX.Element { const [focusRef] = useRestoreFocus(); - const parsedUsername = getUsernameFromSearch(searchTerm); - let username: string | undefined; - let isUsernameChecked = false; - let isUsernameVisible = false; - if (isUsernamesEnabled) { - username = parsedUsername; + const username = getUsernameFromSearch(searchTerm); - isUsernameChecked = selectedContacts.some( - contact => contact.username === username - ); + const isUsernameChecked = selectedContacts.some( + contact => contact.username === username + ); - isUsernameVisible = - Boolean(username) && - username !== ourUsername && - candidateContacts.every(contact => contact.username !== username); - } + const isUsernameVisible = + Boolean(username) && + username !== ourUsername && + candidateContacts.every(contact => contact.username !== username); let phoneNumber: ParsedE164Type | undefined; - if (!parsedUsername) { + if (!username) { phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode); } diff --git a/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx index 74043e1882..d09caaa40a 100644 --- a/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx @@ -126,7 +126,6 @@ const createProps = ( ourE164={undefined} ourUsername={undefined} showUserNotFoundModal={action('showUserNotFoundModal')} - isUsernamesEnabled /> ); }, diff --git a/ts/components/leftPane/LeftPaneChooseGroupMembersHelper.tsx b/ts/components/leftPane/LeftPaneChooseGroupMembersHelper.tsx index 27fa2cc2b0..c121766ff1 100644 --- a/ts/components/leftPane/LeftPaneChooseGroupMembersHelper.tsx +++ b/ts/components/leftPane/LeftPaneChooseGroupMembersHelper.tsx @@ -34,7 +34,6 @@ export type LeftPaneChooseGroupMembersPropsType = { groupSizeHardLimit: number; isShowingRecommendedGroupSizeModal: boolean; isShowingMaximumGroupSizeModal: boolean; - isUsernamesEnabled: boolean; ourE164: string | undefined; ourUsername: string | undefined; searchTerm: string; @@ -73,7 +72,6 @@ export class LeftPaneChooseGroupMembersHelper extends LeftPaneHelper contact.username !== username); - if (isUsernamesEnabled) { - if (isUsernameVisible) { - this.username = username; - } - - this.isUsernameChecked = selectedContacts.some( - contact => contact.username === this.username - ); - } else { - this.isUsernameChecked = false; + if (isUsernameVisible) { + this.username = username; } + this.isUsernameChecked = selectedContacts.some( + contact => contact.username === this.username + ); + const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode); if ( !isUsernameVisible && diff --git a/ts/components/leftPane/LeftPaneComposeHelper.tsx b/ts/components/leftPane/LeftPaneComposeHelper.tsx index b99dfb6847..30bd01e637 100644 --- a/ts/components/leftPane/LeftPaneComposeHelper.tsx +++ b/ts/components/leftPane/LeftPaneComposeHelper.tsx @@ -28,7 +28,6 @@ export type LeftPaneComposePropsType = { regionCode: string | undefined; searchTerm: string; uuidFetchState: UUIDFetchStateType; - isUsernamesEnabled: boolean; }; enum TopButton { @@ -58,7 +57,6 @@ export class LeftPaneComposeHelper extends LeftPaneHelper) { super(); @@ -70,15 +68,10 @@ export class LeftPaneComposeHelper extends LeftPaneHelper contact.username !== username); - } else { - this.isUsernameVisible = false; - } + this.username = username; + this.isUsernameVisible = + Boolean(username) && + this.composeContacts.every(contact => contact.username !== username); const phoneNumber = parseAndFormatPhoneNumber(searchTerm, regionCode); if (!username && phoneNumber) { diff --git a/ts/main/settingsChannel.ts b/ts/main/settingsChannel.ts index 6dd4e7b8a0..c81b3d710c 100644 --- a/ts/main/settingsChannel.ts +++ b/ts/main/settingsChannel.ts @@ -63,7 +63,6 @@ export class SettingsChannel extends EventEmitter { this.installCallback('getAvailableIODevices'); this.installCallback('isPrimary'); this.installCallback('syncRequest'); - this.installCallback('isPhoneNumberSharingEnabled'); // Getters only. These are set by the primary device this.installSetting('blockedCount', { setter: false }); diff --git a/ts/state/selectors/items.ts b/ts/state/selectors/items.ts index 4b8dedd96b..3ae9bb1fe7 100644 --- a/ts/state/selectors/items.ts +++ b/ts/state/selectors/items.ts @@ -73,12 +73,6 @@ export const getServerTimeSkew = createSelector( (state: ItemsStateType): number => state.serverTimeSkew || 0 ); -export const getUsernamesEnabled = createSelector( - getRemoteConfig, - (remoteConfig: ConfigMapType): boolean => - isRemoteConfigFlagEnabled(remoteConfig, 'desktop.usernames') -); - export const getHasCompletedUsernameOnboarding = createSelector( getItems, (state: ItemsStateType): boolean => diff --git a/ts/state/smart/ChooseGroupMembersModal.tsx b/ts/state/smart/ChooseGroupMembersModal.tsx index 19e879500a..997fa519f7 100644 --- a/ts/state/smart/ChooseGroupMembersModal.tsx +++ b/ts/state/smart/ChooseGroupMembersModal.tsx @@ -12,7 +12,6 @@ import type { StatePropsType } from '../../components/conversation/conversation- import { ChooseGroupMembersModal } from '../../components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal'; import { getIntl, getTheme, getRegionCode } from '../selectors/user'; -import { getUsernamesEnabled } from '../selectors/items'; import { getCandidateContactsForNewGroup, getConversationByIdSelector, @@ -59,7 +58,6 @@ const mapStateToProps = ( ourUsername: getMe(state).username, selectedContacts, lookupConversationWithoutServiceId, - isUsernamesEnabled: getUsernamesEnabled(state), }; }; diff --git a/ts/state/smart/LeftPane.tsx b/ts/state/smart/LeftPane.tsx index bb41385e4b..a75733126e 100644 --- a/ts/state/smart/LeftPane.tsx +++ b/ts/state/smart/LeftPane.tsx @@ -39,7 +39,6 @@ import { getPreferredBadgeSelector } from '../selectors/badges'; import { hasNetworkDialog } from '../selectors/network'; import { getPreferredLeftPaneWidth, - getUsernamesEnabled, getUsernameCorrupted, getUsernameLinkCorrupted, getNavTabsCollapsed, @@ -178,7 +177,6 @@ const getModeSpecificProps = ( composeGroups: getFilteredComposeGroups(state), regionCode: getRegionCode(state), searchTerm: getComposerConversationSearchTerm(state), - isUsernamesEnabled: getUsernamesEnabled(state), uuidFetchState: getComposerUUIDFetchState(state), }; case ComposerStep.ChooseGroupMembers: @@ -197,7 +195,6 @@ const getModeSpecificProps = ( regionCode: getRegionCode(state), searchTerm: getComposerConversationSearchTerm(state), selectedContacts: getComposeSelectedContacts(state), - isUsernamesEnabled: getUsernamesEnabled(state), uuidFetchState: getComposerUUIDFetchState(state), }; case ComposerStep.SetGroupMetadata: diff --git a/ts/state/smart/ProfileEditorModal.tsx b/ts/state/smart/ProfileEditorModal.tsx index 953ad38507..4b26de3a15 100644 --- a/ts/state/smart/ProfileEditorModal.tsx +++ b/ts/state/smart/ProfileEditorModal.tsx @@ -13,7 +13,6 @@ import type { StateType } from '../reducer'; import { getIntl } from '../selectors/user'; import { getEmojiSkinTone, - getUsernamesEnabled, getHasCompletedUsernameLinkOnboarding, getUsernameCorrupted, getUsernameLinkColor, @@ -52,7 +51,6 @@ function mapStateToProps( } = getMe(state); const recentEmojis = selectRecentEmojis(state); const skinTone = getEmojiSkinTone(state); - const isUsernameFlagEnabled = getUsernamesEnabled(state); const hasCompletedUsernameLinkOnboarding = getHasCompletedUsernameLinkOnboarding(state); const usernameEditState = getUsernameEditState(state); @@ -75,7 +73,6 @@ function mapStateToProps( hasError: state.globalModals.profileEditorHasError, initialEditState: state.globalModals.profileEditorInitialEditState, i18n: getIntl(state), - isUsernameFlagEnabled, recentEmojis, skinTone, userAvatarData, diff --git a/ts/state/smart/ToastManager.tsx b/ts/state/smart/ToastManager.tsx index 49afb6cef4..5a5a5dbc56 100644 --- a/ts/state/smart/ToastManager.tsx +++ b/ts/state/smart/ToastManager.tsx @@ -25,10 +25,7 @@ import type { ConversationsStateType } from '../ducks/conversations'; import { useToastActions } from '../ducks/toast'; import { useGlobalModalActions } from '../ducks/globalModals'; import { NavTab } from '../ducks/nav'; -import { - getUsernamesEnabled, - getHasCompletedUsernameOnboarding, -} from '../selectors/items'; +import { getHasCompletedUsernameOnboarding } from '../selectors/items'; import { ToastManager } from '../../components/ToastManager'; import type { WidthBreakpoint } from '../../components/_util'; @@ -42,7 +39,6 @@ export function SmartToastManager({ containerWidthBreakpoint, }: SmartPropsType): JSX.Element { const i18n = useSelector(getIntl); - const isUsernameFlagEnabled = useSelector(getUsernamesEnabled); const hasCompletedUsernameOnboarding = useSelector( getHasCompletedUsernameOnboarding ); @@ -69,7 +65,6 @@ export function SmartToastManager({ let megaphone: AnyActionableMegaphone | undefined; if ( - isUsernameFlagEnabled && !hasCompletedUsernameOnboarding && !username && globalModals.usernameOnboardingState === UsernameOnboardingState.NeverShown diff --git a/ts/test-both/RemoteConfig_test.ts b/ts/test-both/RemoteConfig_test.ts index 6abc453d3d..27049b3c55 100644 --- a/ts/test-both/RemoteConfig_test.ts +++ b/ts/test-both/RemoteConfig_test.ts @@ -14,12 +14,12 @@ describe('RemoteConfig', () => { const aci = normalizeAci('95b9729c-51ea-4ddb-b516-652befe78062', 'test'); describe('#innerIsBucketValueEnabled', () => { - // Note: bucketValue is 627610 for 'desktop.pnp' key + // Note: bucketValue is 376321 for 'desktop.internalUser' key it('returns true for 100% wildcard', () => { assert.strictEqual( innerIsBucketValueEnabled( - 'desktop.pnp', + 'desktop.internalUser', '*:1000000', '+12125550000', aci @@ -31,7 +31,7 @@ describe('RemoteConfig', () => { it('returns true for 70% on country code 1', () => { assert.strictEqual( innerIsBucketValueEnabled( - 'desktop.pnp', + 'desktop.internalUser', '1:700000', '+12125550000', aci @@ -40,11 +40,11 @@ describe('RemoteConfig', () => { ); }); - it('returns false for 50% on country code 1', () => { + it('returns false for 30% on country code 1', () => { assert.strictEqual( innerIsBucketValueEnabled( - 'desktop.pnp', - '1:500000', + 'desktop.internalUser', + '1:300000', '+12125550000', aci ), diff --git a/ts/test-both/state/selectors/items_test.ts b/ts/test-both/state/selectors/items_test.ts index 1b403eb5ff..0cab24fc44 100644 --- a/ts/test-both/state/selectors/items_test.ts +++ b/ts/test-both/state/selectors/items_test.ts @@ -8,7 +8,6 @@ import { getPinnedConversationIds, getPreferredLeftPaneWidth, getPreferredReactionEmoji, - getUsernamesEnabled, } from '../../../state/selectors/items'; import type { StateType } from '../../../state/reducer'; import type { ItemsStateType } from '../../../state/ducks/items'; @@ -145,36 +144,4 @@ describe('both/state/selectors/items', () => { assert.deepStrictEqual(actual, preferredReactionEmoji); }); }); - - describe('#getUsernamesEnabled', () => { - it('returns false if the flag is missing or disabled', () => { - [ - {}, - { remoteConfig: {} }, - { - remoteConfig: { - 'desktop.usernames': { - name: 'desktop.usernames' as const, - enabled: false, - }, - }, - }, - ].forEach(itemsState => { - const state = getRootState(itemsState); - assert.isFalse(getUsernamesEnabled(state)); - }); - }); - - it('returns true if the flag is enabled', () => { - const state = getRootState({ - remoteConfig: { - 'desktop.usernames': { - name: 'desktop.usernames' as const, - enabled: true, - }, - }, - }); - assert.isTrue(getUsernamesEnabled(state)); - }); - }); }); diff --git a/ts/test-node/components/leftPane/LeftPaneChooseGroupMembersHelper_test.ts b/ts/test-node/components/leftPane/LeftPaneChooseGroupMembersHelper_test.ts index f059c64226..c15c24aa6e 100644 --- a/ts/test-node/components/leftPane/LeftPaneChooseGroupMembersHelper_test.ts +++ b/ts/test-node/components/leftPane/LeftPaneChooseGroupMembersHelper_test.ts @@ -16,7 +16,6 @@ describe('LeftPaneChooseGroupMembersHelper', () => { candidateContacts: [], isShowingRecommendedGroupSizeModal: false, isShowingMaximumGroupSizeModal: false, - isUsernamesEnabled: true, ourE164: undefined, ourUsername: undefined, groupSizeRecommendedLimit: 22, @@ -55,7 +54,6 @@ describe('LeftPaneChooseGroupMembersHelper', () => { candidateContacts: [], searchTerm: 'foo bar', selectedContacts: [getDefaultConversation()], - isUsernamesEnabled: false, }).getRowCount(), 0 ); @@ -101,7 +99,6 @@ describe('LeftPaneChooseGroupMembersHelper', () => { candidateContacts: [], searchTerm: 'foo bar', selectedContacts: [getDefaultConversation()], - isUsernamesEnabled: false, }).getRow(0) ); }); @@ -115,7 +112,6 @@ describe('LeftPaneChooseGroupMembersHelper', () => { ...defaults, candidateContacts, searchTerm: 'foo bar', - isUsernamesEnabled: false, selectedContacts: [candidateContacts[1]], }); diff --git a/ts/test-node/components/leftPane/LeftPaneComposeHelper_test.ts b/ts/test-node/components/leftPane/LeftPaneComposeHelper_test.ts index 79c1d397cf..d2d41452bd 100644 --- a/ts/test-node/components/leftPane/LeftPaneComposeHelper_test.ts +++ b/ts/test-node/components/leftPane/LeftPaneComposeHelper_test.ts @@ -31,7 +31,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -47,7 +46,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 1 @@ -61,7 +59,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 4 @@ -75,7 +72,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 7 @@ -89,27 +85,12 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'someone.01', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 8 ); }); - it('if usernames are disabled, two less rows are shown', () => { - assert.strictEqual( - new LeftPaneComposeHelper({ - composeContacts: [getDefaultConversation(), getDefaultConversation()], - composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], - regionCode: 'US', - searchTerm: 'someone.54321', - isUsernamesEnabled: false, - uuidFetchState: {}, - }).getRowCount(), - 6 - ); - }); - it('returns the number of conversations + the headers, but not for a phone number', () => { assert.strictEqual( new LeftPaneComposeHelper({ @@ -117,7 +98,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foobar.01', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 2 @@ -128,7 +108,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foobar.01', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 5 @@ -139,7 +118,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'foobar.01', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 7 @@ -153,7 +131,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '+16505551234', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 2 @@ -167,7 +144,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'someone.02', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 2 @@ -181,7 +157,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '+16505551234', - isUsernamesEnabled: true, uuidFetchState: {}, }).getRowCount(), 5 @@ -196,7 +171,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -216,7 +190,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -250,7 +223,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups, regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -279,20 +251,6 @@ describe('LeftPaneComposeHelper', () => { }); }); - it('returns no rows if searching, no results, and usernames are disabled', () => { - const helper = new LeftPaneComposeHelper({ - composeContacts: [], - composeGroups: [], - regionCode: 'US', - searchTerm: 'foo bar', - isUsernamesEnabled: false, - uuidFetchState: {}, - }); - - assert.isUndefined(helper.getRow(0)); - assert.isUndefined(helper.getRow(1)); - }); - it('returns one row per contact if searching', () => { const composeContacts = [ getDefaultConversation(), @@ -303,7 +261,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -325,7 +282,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '+1(650) 555 12 34', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -353,7 +309,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: username, - isUsernamesEnabled: true, uuidFetchState: { [`username:${username}`]: true, }, @@ -381,7 +336,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '+1(650) 555 12 34', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -419,7 +373,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -434,7 +387,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -455,7 +407,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -465,7 +416,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'different search', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -475,7 +425,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'last search', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -487,7 +436,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -497,7 +445,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -509,7 +456,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -519,7 +465,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -529,7 +474,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '+16505551234', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -541,7 +485,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: '', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -551,7 +494,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -563,7 +505,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -573,7 +514,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -583,7 +523,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -593,7 +532,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [], regionCode: 'US', searchTerm: 'foo bar', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); @@ -605,7 +543,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'soup', - isUsernamesEnabled: true, uuidFetchState: {}, }); @@ -615,7 +552,6 @@ describe('LeftPaneComposeHelper', () => { composeGroups: [getDefaultGroupListItem(), getDefaultGroupListItem()], regionCode: 'US', searchTerm: 'soup', - isUsernamesEnabled: true, uuidFetchState: {}, }) ); diff --git a/ts/util/createIPCEvents.ts b/ts/util/createIPCEvents.ts index ad39315be6..5eb2ddf116 100644 --- a/ts/util/createIPCEvents.ts +++ b/ts/util/createIPCEvents.ts @@ -33,7 +33,6 @@ import { PhoneNumberSharingMode } from './phoneNumberSharingMode'; import { strictAssert, assertDev } from './assert'; import * as durations from './durations'; import type { DurationInSeconds } from './durations'; -import { isPhoneNumberSharingEnabled } from './isPhoneNumberSharingEnabled'; import * as Registration from './registration'; import { lookupConversationWithoutServiceId } from './lookupConversationWithoutServiceId'; import * as log from '../logging/log'; @@ -114,7 +113,6 @@ export type IPCEventsCallbacksType = { mediaType: 'screen' | 'microphone' | 'camera' ) => Promise; installStickerPack: (packId: string, key: string) => Promise; - isPhoneNumberSharingEnabled: () => boolean; isPrimary: () => boolean; removeCustomColor: (x: string) => void; removeCustomColorOnConversations: (x: string) => void; @@ -461,7 +459,6 @@ export function createIPCEvents( return window.IPC.setAutoLaunch(value); }, - isPhoneNumberSharingEnabled: () => isPhoneNumberSharingEnabled(), isPrimary: () => window.textsecure.storage.user.getDeviceId() === 1, syncRequest: () => new Promise((resolve, reject) => { diff --git a/ts/util/isPhoneNumberSharingEnabled.ts b/ts/util/isPhoneNumberSharingEnabled.ts deleted file mode 100644 index 50ce0e220a..0000000000 --- a/ts/util/isPhoneNumberSharingEnabled.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2021 Signal Messenger, LLC -// SPDX-License-Identifier: AGPL-3.0-only - -import * as RemoteConfig from '../RemoteConfig'; - -export function isPhoneNumberSharingEnabled(): boolean { - return Boolean( - RemoteConfig.isEnabled('desktop.internalUser') || - RemoteConfig.isEnabled('desktop.pnp') - ); -} diff --git a/ts/windows/preload.ts b/ts/windows/preload.ts index b17e8333fe..5c111a56a0 100644 --- a/ts/windows/preload.ts +++ b/ts/windows/preload.ts @@ -30,7 +30,6 @@ installSetting('typingIndicatorSetting', { }); installCallback('deleteAllMyStories'); -installCallback('isPhoneNumberSharingEnabled'); installCallback('isPrimary'); installCallback('syncRequest'); diff --git a/ts/windows/settings/app.tsx b/ts/windows/settings/app.tsx index 3d12c15521..573992a149 100644 --- a/ts/windows/settings/app.tsx +++ b/ts/windows/settings/app.tsx @@ -62,7 +62,6 @@ SettingsWindowProps.onRender( isHideMenuBarSupported, isMinimizeToAndStartInSystemTraySupported, isNotificationAttentionSupported, - isPhoneNumberSharingSupported, isSyncSupported, isSystemTraySupported, lastSyncTime, @@ -167,7 +166,6 @@ SettingsWindowProps.onRender( isMinimizeToAndStartInSystemTraySupported } isNotificationAttentionSupported={isNotificationAttentionSupported} - isPhoneNumberSharingSupported={isPhoneNumberSharingSupported} isSyncSupported={isSyncSupported} isSystemTraySupported={isSystemTraySupported} lastSyncTime={lastSyncTime} diff --git a/ts/windows/settings/preload.ts b/ts/windows/settings/preload.ts index 1d2a9cc05a..c390a2edf2 100644 --- a/ts/windows/settings/preload.ts +++ b/ts/windows/settings/preload.ts @@ -83,7 +83,6 @@ const ipcGetAvailableIODevices = createCallback('getAvailableIODevices'); const ipcGetCustomColors = createCallback('getCustomColors'); const ipcIsSyncNotSupported = createCallback('isPrimary'); const ipcMakeSyncRequest = createCallback('syncRequest'); -const ipcPNP = createCallback('isPhoneNumberSharingEnabled'); const ipcDeleteAllMyStories = createCallback('deleteAllMyStories'); // ChatColorPicker redux hookups @@ -161,7 +160,6 @@ async function renderPreferences() { hasStoriesDisabled, hasTextFormatting, hasTypingIndicators, - isPhoneNumberSharingSupported, lastSyncTime, notificationContent, phoneNumber, @@ -204,7 +202,6 @@ async function renderPreferences() { hasStoriesDisabled: settingHasStoriesDisabled.getValue(), hasTextFormatting: settingTextFormatting.getValue(), hasTypingIndicators: settingTypingIndicators.getValue(), - isPhoneNumberSharingSupported: ipcPNP(), lastSyncTime: settingLastSyncTime.getValue(), notificationContent: settingNotificationSetting.getValue(), phoneNumber: settingPhoneNumber.getValue(), @@ -312,7 +309,6 @@ async function renderPreferences() { isAutoLaunchSupported: Settings.isAutoLaunchSupported(OS), isHideMenuBarSupported: Settings.isHideMenuBarSupported(OS), isNotificationAttentionSupported: Settings.isDrawAttentionSupported(OS), - isPhoneNumberSharingSupported, isSyncSupported: !isSyncNotSupported, isSystemTraySupported: Settings.isSystemTraySupported( OS,