From 8fd298feb5483321580ed16e2205d0083cda6f97 Mon Sep 17 00:00:00 2001 From: Wojciech Lewicki Date: Thu, 20 Jun 2024 17:42:14 +0200 Subject: [PATCH] feat: go back to OD when trying to sign out --- src/libs/actions/Session/index.ts | 5 ++ src/pages/settings/InitialSettingsPage.tsx | 71 +++++++++++----------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index e85fdc9d1531..de9d85917289 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -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. diff --git a/src/pages/settings/InitialSettingsPage.tsx b/src/pages/settings/InitialSettingsPage.tsx index 8fa152d5c06a..564e595f745d 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 {withOnyx} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; @@ -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;