From 84788f13ca3225dfaddd4231f8480212ad4918b6 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 27 Aug 2024 13:17:18 +0200 Subject: [PATCH 1/4] do not show exit survey in HybridApp --- src/ONYXKEYS.ts | 4 ---- src/libs/API/types.ts | 1 - src/libs/actions/ExitSurvey.ts | 21 ++++--------------- .../ExitSurvey/ExitSurveyConfirmPage.tsx | 18 +++------------- src/pages/settings/InitialSettingsPage.tsx | 11 +++++++++- 5 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index b7b6cf53a176..0f006657cf9b 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -275,9 +275,6 @@ const ONYXKEYS = { /** Is report data loading? */ IS_LOADING_APP: 'isLoadingApp', - /** Is the user in the process of switching to OldDot? */ - IS_SWITCHING_TO_OLD_DOT: 'isSwitchingToOldDot', - /** Is the test tools modal open? */ IS_TEST_TOOLS_MODAL_OPEN: 'isTestToolsModalOpen', @@ -842,7 +839,6 @@ type OnyxValuesMapping = { [ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN]: boolean; [ONYXKEYS.APP_PROFILING_IN_PROGRESS]: boolean; [ONYXKEYS.IS_LOADING_APP]: boolean; - [ONYXKEYS.IS_SWITCHING_TO_OLD_DOT]: boolean; [ONYXKEYS.WALLET_TRANSFER]: OnyxTypes.WalletTransfer; [ONYXKEYS.LAST_ACCESSED_WORKSPACE_POLICY_ID]: string; [ONYXKEYS.SHOULD_SHOW_COMPOSE_INPUT]: boolean; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index cc3504ad89ab..20ead12aa62e 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -800,7 +800,6 @@ const SIDE_EFFECT_REQUEST_COMMANDS = { RECONNECT_APP: 'ReconnectApp', ADD_PAYMENT_CARD_GBP: 'AddPaymentCardGBP', REVEAL_EXPENSIFY_CARD_DETAILS: 'RevealExpensifyCardDetails', - SWITCH_TO_OLD_DOT: 'SwitchToOldDot', TWO_FACTOR_AUTH_VALIDATE: 'TwoFactorAuth_Validate', } as const; diff --git a/src/libs/actions/ExitSurvey.ts b/src/libs/actions/ExitSurvey.ts index 12dc57f1dfde..43f73f4a2764 100644 --- a/src/libs/actions/ExitSurvey.ts +++ b/src/libs/actions/ExitSurvey.ts @@ -1,7 +1,7 @@ import type {OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import * as API from '@libs/API'; -import {SIDE_EFFECT_REQUEST_COMMANDS} from '@libs/API/types'; +import {WRITE_COMMANDS} from '@libs/API/types'; import ONYXKEYS from '@src/ONYXKEYS'; import REASON_INPUT_IDS from '@src/types/form/ExitSurveyReasonForm'; import type {ExitReason} from '@src/types/form/ExitSurveyReasonForm'; @@ -31,19 +31,6 @@ function saveResponse(response: string) { */ function switchToOldDot() { const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.IS_SWITCHING_TO_OLD_DOT, - value: true, - }, - ]; - - const finallyData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.SET, - key: ONYXKEYS.IS_SWITCHING_TO_OLD_DOT, - value: false, - }, { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.FORMS.EXIT_SURVEY_REASON_FORM, @@ -67,13 +54,13 @@ function switchToOldDot() { ]; // eslint-disable-next-line rulesdir/no-api-side-effects-method - return API.makeRequestWithSideEffects( - SIDE_EFFECT_REQUEST_COMMANDS.SWITCH_TO_OLD_DOT, + API.write( + WRITE_COMMANDS.SWITCH_TO_OLD_DOT, { reason: exitReason, surveyResponse: exitSurveyResponse, }, - {optimisticData, finallyData}, + {optimisticData}, ); } diff --git a/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx b/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx index 2c9fa879dcfc..2e567fe82974 100644 --- a/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx +++ b/src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx @@ -1,6 +1,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useCallback, useEffect} from 'react'; -import {NativeModules, View} from 'react-native'; +import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; import Icon from '@components//Icon'; @@ -28,12 +28,11 @@ import ExitSurveyOffline from './ExitSurveyOffline'; type ExitSurveyConfirmPageOnyxProps = { exitReason?: ExitReason | null; - isLoading: OnyxEntry; }; type ExitSurveyConfirmPageProps = ExitSurveyConfirmPageOnyxProps & StackScreenProps; -function ExitSurveyConfirmPage({exitReason, isLoading, route, navigation}: ExitSurveyConfirmPageProps) { +function ExitSurveyConfirmPage({exitReason, route, navigation}: ExitSurveyConfirmPageProps) { const {translate} = useLocalize(); const {isOffline} = useNetwork(); const styles = useThemeStyles(); @@ -84,18 +83,10 @@ function ExitSurveyConfirmPage({exitReason, isLoading, route, navigation}: ExitS large text={translate('exitSurvey.goToExpensifyClassic')} onPress={() => { - const promise = ExitSurvey.switchToOldDot(); - if (NativeModules.HybridAppModule) { - promise.then(() => { - Navigation.resetToHome(); - NativeModules.HybridAppModule.closeReactNativeApp(false); - }); - return; - } + ExitSurvey.switchToOldDot(); Navigation.dismissModal(); Link.openOldDotLink(CONST.OLDDOT_URLS.INBOX); }} - isLoading={isLoading ?? false} isDisabled={isOffline} /> @@ -110,7 +101,4 @@ export default withOnyx) => value?.[EXIT_SURVEY_REASON_INPUT_IDS.REASON] ?? null, }, - isLoading: { - key: ONYXKEYS.IS_SWITCHING_TO_OLD_DOT, - }, })(ExitSurveyConfirmPage); diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 20e42aba01d8..00c914b1f989 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -148,7 +148,16 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa { translationKey: 'exitSurvey.goToExpensifyClassic', icon: Expensicons.ExpensifyLogoNew, - routeName: ROUTES.SETTINGS_EXIT_SURVEY_REASON, + ...(NativeModules.HybridAppModule + ? { + action: () => { + Navigation.resetToHome(); + NativeModules.HybridAppModule.closeReactNativeApp(false); + }, + } + : { + route: ROUTES.SETTINGS_EXIT_SURVEY_REASON, + }), }, { translationKey: 'common.profile', From 9b548fa432969a8e77f74970ae7a681349303274 Mon Sep 17 00:00:00 2001 From: war-in Date: Tue, 27 Aug 2024 15:36:05 +0200 Subject: [PATCH 2/4] add isSwitchingToOldDot param --- src/libs/actions/Session/index.ts | 2 +- src/pages/settings/InitialSettingsPage.tsx | 5 ++--- src/types/modules/react-native.d.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index c06e6087d336..e889a934b6ec 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -206,7 +206,7 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess if (!isAnonymousUser()) { // In the HybridApp, we want the Old Dot to handle the sign out process if (NativeModules.HybridAppModule && killHybridApp) { - NativeModules.HybridAppModule.closeReactNativeApp(true); + NativeModules.HybridAppModule.closeReactNativeApp(true, false); return; } // We'll only call signOut if we're not stashing the session and this is not a supportal session, diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 00c914b1f989..2f398a7e0e25 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -2,7 +2,7 @@ import {useRoute} from '@react-navigation/native'; import React, {useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react'; // eslint-disable-next-line no-restricted-imports import type {GestureResponderEvent, ScrollView as RNScrollView, ScrollViewProps, StyleProp, ViewStyle} from 'react-native'; -import {View} from 'react-native'; +import {NativeModules, View} from 'react-native'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import {useOnyx, withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -151,8 +151,7 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa ...(NativeModules.HybridAppModule ? { action: () => { - Navigation.resetToHome(); - NativeModules.HybridAppModule.closeReactNativeApp(false); + NativeModules.HybridAppModule.closeReactNativeApp(false, true); }, } : { diff --git a/src/types/modules/react-native.d.ts b/src/types/modules/react-native.d.ts index 2fc9402157e0..71ac4b8faff7 100644 --- a/src/types/modules/react-native.d.ts +++ b/src/types/modules/react-native.d.ts @@ -5,7 +5,7 @@ import type {EnvironmentCheckerModule} from '@libs/Environment/betaChecker/types import type StartupTimer from '@libs/StartupTimer/types'; type HybridAppModule = { - closeReactNativeApp: (shouldSignOut: boolean) => void; + closeReactNativeApp: (shouldSignOut: boolean, isSwitchingToOldDot: boolean) => void; completeOnboarding: (status: boolean) => void; exitApp: () => void; }; From b0f713b0b43f6a22e5b7b777d58d8ad3f74392d3 Mon Sep 17 00:00:00 2001 From: war-in Date: Wed, 28 Aug 2024 17:46:58 +0200 Subject: [PATCH 3/4] rename argument --- src/types/modules/react-native.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/modules/react-native.d.ts b/src/types/modules/react-native.d.ts index 71ac4b8faff7..7e3f299ad938 100644 --- a/src/types/modules/react-native.d.ts +++ b/src/types/modules/react-native.d.ts @@ -5,7 +5,7 @@ import type {EnvironmentCheckerModule} from '@libs/Environment/betaChecker/types import type StartupTimer from '@libs/StartupTimer/types'; type HybridAppModule = { - closeReactNativeApp: (shouldSignOut: boolean, isSwitchingToOldDot: boolean) => void; + closeReactNativeApp: (shouldSignOut: boolean, shouldSetNVP: boolean) => void; completeOnboarding: (status: boolean) => void; exitApp: () => void; }; From ccc2c04b5a2612ce9e60e7a11fac3260caaa6864 Mon Sep 17 00:00:00 2001 From: war-in Date: Thu, 29 Aug 2024 08:43:54 +0200 Subject: [PATCH 4/4] fix misspelled argument name `route` -> `routeName` --- src/pages/settings/InitialSettingsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 2f398a7e0e25..b14579c65aa3 100755 --- a/src/pages/settings/InitialSettingsPage.tsx +++ b/src/pages/settings/InitialSettingsPage.tsx @@ -155,7 +155,7 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa }, } : { - route: ROUTES.SETTINGS_EXIT_SURVEY_REASON, + routeName: ROUTES.SETTINGS_EXIT_SURVEY_REASON, }), }, {