Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add named params in HybridAppModule methods #153

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ScreenWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ function ScreenWrapper(
}, [route?.params]);

UNSTABLE_usePreventRemove(shouldReturnToOldDot, () => {
NativeModules.HybridAppModule?.closeReactNativeApp(false, false);
NativeModules.HybridAppModule?.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
});

const panResponder = useRef(
Expand Down
16 changes: 8 additions & 8 deletions src/libs/HybridApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ function handleChangeInHybridAppSignInFlow(hybridApp: OnyxEntry<HybridApp>, tryN

if (hybridApp?.newDotSignInState === CONST.HYBRID_APP_SIGN_IN_STATE.FINISHED && tryNewDot !== undefined && !!credentials?.autoGeneratedLogin && !!credentials?.autoGeneratedPassword) {
Log.info(`[HybridApp] Performing sign-in${shouldUseOldApp(tryNewDot) ? '' : ' (in background)'} on OldDot side`);
NativeModules.HybridAppModule.signInToOldDot(
credentials.autoGeneratedLogin,
credentials.autoGeneratedPassword,
currentSession?.authToken ?? '',
getCurrentUserEmail() ?? '',
activePolicyID ?? '',
);
NativeModules.HybridAppModule.signInToOldDot({
autoGeneratedLogin: credentials.autoGeneratedLogin,
autoGeneratedPassword: credentials.autoGeneratedPassword,
authToken: currentSession?.authToken ?? '',
email: getCurrentUserEmail() ?? '',
policyID: activePolicyID ?? '',
});
HybridAppActions.setUseNewDotSignInPage(false).then(() => {
if (shouldUseOldApp(tryNewDot)) {
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
} else {
Log.info('[HybridApp] The user should see NewDot. There is no need to block the user on the `SignInPage` until the sign-in process is completed on the OldDot side.');
HybridAppActions.setReadyToShowAuthScreens(true);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/TripReservationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function bookATrip(translate: LocaleContextProps['translate'], setCtaErrorMessag
}

Log.info('[HybridApp] Returning to OldDot after opening TravelDot');
NativeModules.HybridAppModule.closeReactNativeApp(false, false);
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: false});
})
?.catch(() => {
setCtaErrorMessage(translate('travel.errorMessage'));
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function connect(email: string) {
confirmReadyToOpenApp();
openApp();

NativeModules.HybridAppModule.switchAccount(email);
NativeModules.HybridAppModule.switchAccount({newDotCurrentAccount: email});
});
})
.catch((error) => {
Expand Down Expand Up @@ -210,7 +210,7 @@ function disconnect() {
confirmReadyToOpenApp();
openApp();

NativeModules.HybridAppModule.switchAccount(getCurrentUserEmail() ?? '');
NativeModules.HybridAppModule.switchAccount({newDotCurrentAccount: getCurrentUserEmail() ?? ''});
});
})
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function completeHybridAppOnboarding() {

// No matter what the response is, we want to mark the onboarding as completed (user saw the explanation modal)
Log.info(`[HybridApp] Onboarding status has changed. Propagating new value to OldDot`, true);
NativeModules.HybridAppModule.completeOnboarding(true);
NativeModules.HybridAppModule.completeOnboarding({status: true});
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/ErrorPage/SessionExpiredPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function SessionExpiredPage() {
Navigation.goBack();
return;
}
NativeModules.HybridAppModule.closeReactNativeApp(true, false);
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: true, shouldSetNVP: false});
}}
>
{translate('deeplinkWrapper.signIn')}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
...(NativeModules.HybridAppModule
? {
action: () => {
NativeModules.HybridAppModule.closeReactNativeApp(false, true);
NativeModules.HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: true});
setInitialURL(undefined);
},
}
Expand Down
8 changes: 4 additions & 4 deletions src/types/modules/react-native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {ShortcutManagerModule} from '@libs/ShortcutManager';
import type StartupTimer from '@libs/StartupTimer/types';

type HybridAppModule = {
closeReactNativeApp: (shouldSignOut: boolean, shouldSetNVP: boolean) => void;
completeOnboarding: (status: boolean) => void;
switchAccount: (newDotCurrentAccount: string) => void;
signInToOldDot: (autoGeneratedLogin: string, autoGeneratedPassword: string, authToken: string, email: string, policyID: string) => void;
closeReactNativeApp: ({shouldSignOut: boolean, shouldSetNVP: boolean}) => void;
completeOnboarding: ({status: boolean}) => void;
switchAccount: ({newDotCurrentAccount: string}) => void;
signInToOldDot: ({autoGeneratedLogin: string, autoGeneratedPassword: string, authToken: string, email: string, policyID: string}) => void;
signOutFromOldDot: () => void;
exitApp: () => void;
};
Expand Down
Loading