more advances on initial launch

This commit is contained in:
Pablo Velez Vidal 2022-11-12 17:06:07 +01:00
parent 5b09f03ac1
commit ca053ed9c4
3 changed files with 21 additions and 23 deletions

View file

@ -19,7 +19,6 @@ import {convertToNotificationData} from '@utils/notification';
import {parseDeepLink} from '@utils/url';
import type {DeepLinkChannel, DeepLinkDM, DeepLinkGM, DeepLinkPermalink, DeepLinkWithData, LaunchProps} from '@typings/launch';
import { fetchConfigAndLicense } from '@actions/remote/systems';
const initialNotificationTypes = [PushNotification.NOTIFICATION_TYPE.MESSAGE, PushNotification.NOTIFICATION_TYPE.SESSION];
@ -59,7 +58,6 @@ const launchAppFromNotification = async (notification: NotificationWithData) =>
launchApp(props);
};
// pablo - here I need to validate the logic for launching the onboarding screen
const launchApp = async (props: LaunchProps, resetNavigation = true) => {
let serverUrl: string | undefined;
switch (props?.launchType) {
@ -102,10 +100,9 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => {
// if (!onboardingAlreadyShown) {
// here, check if there is not an active session and redirect to onboarding with a flag, so the sign in button will
// redirect to the sign in
// return launchToOnboarding(props, goToLoginPage);
// return launchToOnboarding(props, goToLoginServerUrlPage);
// }
console.log('\n\n first launch to onboarding \n\n', serverUrl);
return launchToOnboarding(props, resetNavigation, false, false, true, serverUrl);
return launchToOnboarding(props, resetNavigation, false, false, serverUrl);
let launchType = props.launchType;
if (!hasCurrentUser) {
@ -139,7 +136,6 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => {
// if (onboardingAlreadyShown) {
// // launchToServer(props, resetNavigation);
// }
console.log('\n\n second launch to onboarding \n\n', serverUrl);
return launchToOnboarding(props, resetNavigation);
};
@ -199,8 +195,7 @@ const launchToOnboarding = (
resetNavigation = true,
notActiveSession = true,
whiteLabeledApp = false,
goToLogIn = true,
serverUrl = '',
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
@ -208,8 +203,8 @@ const launchToOnboarding = (
launchToServer(props, resetNavigation);
}
// if there is not an active session, pass the prop and redirect to the LOGIN page (keep in mind all the redirection login to check for SSO stuff)
return resetToOnboarding(props, true, serverUrl);
// 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) => {

View file

@ -281,7 +281,7 @@ export function resetToSelectServer(passProps: LaunchProps) {
});
}
export function resetToOnboarding(passProps: LaunchProps, goToLogIn: boolean, serverUrl: 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,8 +295,7 @@ export function resetToOnboarding(passProps: LaunchProps, goToLogIn: boolean, se
passProps: {
...passProps,
theme,
goToLogIn,
serverUrl,
goToLoginServerUrl,
},
options: {
layout: {
@ -411,6 +410,10 @@ export function goToScreen(name: string, title: string, passProps = {}, options
},
};
if (name === Screens.SERVER) {
console.log('\n\n** screen pass props', passProps, componentId, name, '\n\n');
}
return Navigation.push(componentId, {
component: {
id: name,

View file

@ -21,16 +21,14 @@ import type {LaunchProps} from '@typings/launch';
interface OnboardingProps extends LaunchProps {
theme: Theme;
goToLogIn: boolean;
serverUrl: string;
goToLoginServerUrl: string;
}
const AnimatedSafeArea = Animated.createAnimatedComponent(SafeAreaView);
const Onboarding = ({
theme,
goToLogIn,
serverUrl,
goToLoginServerUrl,
}: OnboardingProps) => {
const {width} = useWindowDimensions();
const styles = getStyleSheet(theme);
@ -72,7 +70,7 @@ const Onboarding = ({
}, [currentIndex.value, slidesRef.current, moveToSlide]);
const initLogin = async () => {
const data = await fetchConfigAndLicense(serverUrl, true);
const data = await fetchConfigAndLicense(goToLoginServerUrl, true);
if (data.error) {
console.log('Error getting the config and license information');
return;
@ -89,7 +87,7 @@ const Onboarding = ({
hasLoginForm,
license,
serverDisplayName: displayName,
serverUrl,
serverUrl: goToLoginServerUrl,
ssoOptions,
theme,
};
@ -105,9 +103,6 @@ const Onboarding = ({
};
const signInHandler = useCallback(() => {
if (goToLogIn) {
initLogin();
}
const topBar = {
visible: true,
drawBehind: true,
@ -121,8 +116,13 @@ const Onboarding = ({
title: '',
},
};
if (goToLoginServerUrl) {
initLogin();
return;
}
goToScreen(Screens.SERVER, '', {theme}, {topBar});
}, [goToLogIn]);
}, [goToLoginServerUrl]);
const renderSlide = useCallback(({item, index}: ListRenderItemInfo<OnboardingItem>) => {
return (