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

Re-add Sign out button to HybridApp #47415

Merged
merged 5 commits into from
Aug 20, 2024
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/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
NativeModules.HybridAppModule.closeReactNativeApp(true);
return;
}
// We'll only call signOut if we're not stashing the session and this is not a supportal session,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/ExitSurvey/ExitSurveyConfirmPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function ExitSurveyConfirmPage({exitReason, isLoading, route, navigation}: ExitS
if (NativeModules.HybridAppModule) {
promise.then(() => {
Navigation.resetToHome();
NativeModules.HybridAppModule.closeReactNativeApp();
NativeModules.HybridAppModule.closeReactNativeApp(false);
});
return;
}
Expand Down
75 changes: 36 additions & 39 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 {NativeModules, View} from 'react-native';
import {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';
Expand Down Expand Up @@ -229,49 +229,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 = {
return {
sectionStyle: {
...styles.pt4,
},
sectionTranslationKey: 'initialSettingsPage.general',
items: NativeModules.HybridAppModule ? commonItems : [...commonItems, signOutItem],
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);
},
},
],
};

return defaultMenu;
}, [styles.pt4, signOut]);

/**
Expand Down
2 changes: 1 addition & 1 deletion src/types/modules/react-native.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {EnvironmentCheckerModule} from '@libs/Environment/betaChecker/types
import type StartupTimer from '@libs/StartupTimer/types';

type HybridAppModule = {
closeReactNativeApp: () => void;
closeReactNativeApp: (shouldSignOut: boolean) => void;
completeOnboarding: (status: boolean) => void;
exitApp: () => void;
};
Expand Down
Loading