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

[HybridApp] feat: go back to OD when trying to sign out #44092

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
5 changes: 5 additions & 0 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ function signOutAndRedirectToSignIn(shouldResetToHome?: boolean, shouldStashSess
Log.info('Redirecting to Sign In because signOut() was called');
hideContextMenu(false);
if (!isAnonymousUser()) {
// In the HybridApp, we want the Old Dot to handle the sign out process
if (NativeModules.HybridAppModule) {
NativeModules.HybridAppModule.closeReactNativeApp();
return;
}
// We'll only call signOut if we're not stashing the session and this is not a supportal session,
// otherwise we'll call the API to invalidate the autogenerated credentials used for infinite
// session.
Expand Down
71 changes: 36 additions & 35 deletions src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {withOnyx} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
Expand Down Expand Up @@ -225,45 +225,46 @@ function InitialSettingsPage({session, userWallet, bankAccountList, fundList, wa
*/
const generalMenuItemsData: Menu = useMemo(() => {
const signOutTranslationKey = Session.isSupportAuthToken() && Session.hasStashedSession() ? 'initialSettingsPage.restoreStashed' : 'initialSettingsPage.signOut';
const commonItems: MenuData[] = [
{
translationKey: 'initialSettingsPage.help',
icon: Expensicons.QuestionMark,
action: () => {
Link.openExternalLink(CONST.NEWHELP_URL);
},
iconRight: Expensicons.NewWindow,
shouldShowRightIcon: true,
link: CONST.NEWHELP_URL,
},
{
translationKey: 'initialSettingsPage.about',
icon: Expensicons.Info,
routeName: ROUTES.SETTINGS_ABOUT,
},
{
translationKey: 'initialSettingsPage.aboutPage.troubleshoot',
icon: Expensicons.Lightbulb,
routeName: ROUTES.SETTINGS_TROUBLESHOOT,
},
{
translationKey: 'sidebarScreen.saveTheWorld',
icon: Expensicons.Heart,
routeName: ROUTES.SETTINGS_SAVE_THE_WORLD,
},
];
const signOutItem: MenuData = {
translationKey: signOutTranslationKey,
icon: Expensicons.Exit,
action: () => {
signOut(false);
},
};
const defaultMenu: Menu = {
sectionStyle: {
...styles.pt4,
},
sectionTranslationKey: 'initialSettingsPage.general',
items: [
{
translationKey: 'initialSettingsPage.help',
icon: Expensicons.QuestionMark,
action: () => {
Link.openExternalLink(CONST.NEWHELP_URL);
},
iconRight: Expensicons.NewWindow,
shouldShowRightIcon: true,
link: CONST.NEWHELP_URL,
},
{
translationKey: 'initialSettingsPage.about',
icon: Expensicons.Info,
routeName: ROUTES.SETTINGS_ABOUT,
},
{
translationKey: 'initialSettingsPage.aboutPage.troubleshoot',
icon: Expensicons.Lightbulb,
routeName: ROUTES.SETTINGS_TROUBLESHOOT,
},
{
translationKey: 'sidebarScreen.saveTheWorld',
icon: Expensicons.Heart,
routeName: ROUTES.SETTINGS_SAVE_THE_WORLD,
},
{
translationKey: signOutTranslationKey,
icon: Expensicons.Exit,
action: () => {
signOut(false);
},
},
],
items: NativeModules.HybridAppModule ? commonItems : [...commonItems, signOutItem],
};

return defaultMenu;
Expand Down
Loading