Skip to content

Commit

Permalink
feat: go back to OD when trying to sign out
Browse files Browse the repository at this point in the history
  • Loading branch information
WoLewicki committed Jun 20, 2024
1 parent f618a94 commit 8fd298f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 35 deletions.
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

0 comments on commit 8fd298f

Please sign in to comment.