From b398c90f898844cf3ea93a0aa3ce4d0559768516 Mon Sep 17 00:00:00 2001 From: Pablo Velez Vidal Date: Tue, 15 Nov 2022 13:33:27 +0100 Subject: [PATCH] simplyfy signatures --- app/init/launch.ts | 27 ++++++--------------------- app/screens/navigation.ts | 3 +-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/app/init/launch.ts b/app/init/launch.ts index eccfbf422..bb079026d 100644 --- a/app/init/launch.ts +++ b/app/init/launch.ts @@ -99,8 +99,9 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => { hasCurrentUser = Boolean(currentUserId); } - if (!onboadingViewed) { - return launchToOnboarding(props, resetNavigation, false, false, serverUrl); + // invert this logic + if (onboadingViewed) { + return resetToOnboarding({...props, goToLoginServerUrl: serverUrl}); } let launchType = props.launchType; @@ -132,10 +133,11 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => { } } - if (onboadingViewed) { + // invert this logic + if (!onboadingViewed) { return launchToServer(props, resetNavigation); } - return launchToOnboarding(props, resetNavigation); + return resetToOnboarding(props); }; const launchToHome = async (props: LaunchProps) => { @@ -189,23 +191,6 @@ const launchToServer = (props: LaunchProps, resetNavigation: Boolean) => { return goToScreen(Screens.SERVER, title, {...props}); }; -const launchToOnboarding = ( - props: LaunchProps, - resetNavigation = true, - notActiveSession = true, - whiteLabeledApp = false, - goToLoginServerUrl = '', -) => { - // here, if there is an active session, redirect to home - // if there is a whitelabeled app, redirect to either SERVER or LOGIN but don't show the onboarding - if (resetNavigation) { - launchToServer(props, resetNavigation); - } - - // goToLoginServerUrl will contain a value when there is a server already configured but not a active session - return resetToOnboarding(props, goToLoginServerUrl); -}; - export const relaunchApp = (props: LaunchProps, resetNavigation = false) => { return launchApp(props, resetNavigation); }; diff --git a/app/screens/navigation.ts b/app/screens/navigation.ts index 32c03db7c..f2274f81e 100644 --- a/app/screens/navigation.ts +++ b/app/screens/navigation.ts @@ -281,7 +281,7 @@ export function resetToSelectServer(passProps: LaunchProps) { }); } -export function resetToOnboarding(passProps: LaunchProps, goToLoginServerUrl: string) { +export function resetToOnboarding(passProps: LaunchProps & {goToLoginServerUrl?: string}) { const theme = getDefaultThemeByAppearance(); const isDark = tinyColor(theme.sidebarBg).isDark(); StatusBar.setBarStyle(isDark ? 'light-content' : 'dark-content'); @@ -295,7 +295,6 @@ export function resetToOnboarding(passProps: LaunchProps, goToLoginServerUrl: st passProps: { ...passProps, theme, - goToLoginServerUrl, }, options: { layout: {