simplyfy signatures

This commit is contained in:
Pablo Velez Vidal 2022-11-15 13:33:27 +01:00
parent 375d64c35e
commit b398c90f89
2 changed files with 7 additions and 23 deletions

View file

@ -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);
};

View file

@ -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: {