forked from Ivasoft/mattermost-mobile
Add logic to don't show the onboarding once it has been shown once
This commit is contained in:
@@ -28,6 +28,18 @@ export const storeMultiServerTutorial = async (prepareRecordsOnly = false) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const storeOnboardingViewedValue = async (prepareRecordsOnly = false) => {
|
||||
try {
|
||||
const {operator} = DatabaseManager.getAppDatabaseAndOperator();
|
||||
return operator.handleGlobal({
|
||||
globals: [{id: GLOBAL_IDENTIFIERS.ONBOARDING, value: 'true'}],
|
||||
prepareRecordsOnly,
|
||||
});
|
||||
} catch (error) {
|
||||
return {error};
|
||||
}
|
||||
};
|
||||
|
||||
export const storeProfileLongPressTutorial = async (prepareRecordsOnly = false) => {
|
||||
try {
|
||||
const {operator} = DatabaseManager.getAppDatabaseAndOperator();
|
||||
|
||||
@@ -72,6 +72,7 @@ export const GLOBAL_IDENTIFIERS = {
|
||||
DEVICE_TOKEN: 'deviceToken',
|
||||
MULTI_SERVER_TUTORIAL: 'multiServerTutorial',
|
||||
PROFILE_LONG_PRESS_TUTORIAL: 'profileLongPressTutorial',
|
||||
ONBOARDING: 'onboarding',
|
||||
};
|
||||
|
||||
export enum OperationType {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {appEntry, pushNotificationEntry, upgradeEntry} from '@actions/remote/ent
|
||||
import {Screens, DeepLink, Events, Launch, PushNotification} from '@constants';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {getActiveServerUrl, getServerCredentials, removeServerCredentials} from '@init/credentials';
|
||||
import {onboadingViewedValue} from '@queries/app/global';
|
||||
import {getThemeForCurrentTeam} from '@queries/servers/preference';
|
||||
import {getCurrentUserId} from '@queries/servers/system';
|
||||
import {queryMyTeams} from '@queries/servers/team';
|
||||
@@ -59,6 +60,7 @@ const launchAppFromNotification = async (notification: NotificationWithData) =>
|
||||
};
|
||||
|
||||
const launchApp = async (props: LaunchProps, resetNavigation = true) => {
|
||||
const onboadingViewed = await onboadingViewedValue();
|
||||
let serverUrl: string | undefined;
|
||||
switch (props?.launchType) {
|
||||
case Launch.DeepLink:
|
||||
@@ -97,12 +99,9 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => {
|
||||
hasCurrentUser = Boolean(currentUserId);
|
||||
}
|
||||
|
||||
// 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, goToLoginServerUrlPage);
|
||||
// }
|
||||
return launchToOnboarding(props, resetNavigation, false, false, serverUrl);
|
||||
if (!onboadingViewed) {
|
||||
return launchToOnboarding(props, resetNavigation, false, false, serverUrl);
|
||||
}
|
||||
|
||||
let launchType = props.launchType;
|
||||
if (!hasCurrentUser) {
|
||||
@@ -133,9 +132,9 @@ const launchApp = async (props: LaunchProps, resetNavigation = true) => {
|
||||
}
|
||||
}
|
||||
|
||||
// if (onboardingAlreadyShown) {
|
||||
// // launchToServer(props, resetNavigation);
|
||||
// }
|
||||
if (onboadingViewed) {
|
||||
return launchToServer(props, resetNavigation);
|
||||
}
|
||||
return launchToOnboarding(props, resetNavigation);
|
||||
};
|
||||
|
||||
|
||||
@@ -28,6 +28,19 @@ export const observeMultiServerTutorial = (appDatabase: Database) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const onboadingViewedValue = async (): Promise<boolean> => {
|
||||
const appDatabase = DatabaseManager.appDatabase?.database;
|
||||
if (!appDatabase) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
const onboardingVal = await appDatabase.get<GlobalModel>(GLOBAL).find(GLOBAL_IDENTIFIERS.ONBOARDING);
|
||||
return Boolean(onboardingVal?.value) || false;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
export const observeProfileLongPresTutorial = () => {
|
||||
const appDatabase = DatabaseManager.appDatabase?.database;
|
||||
if (!appDatabase) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import React, {useCallback, useEffect, useRef} from 'react';
|
||||
import {View, ListRenderItemInfo, useWindowDimensions, SafeAreaView, ScrollView, Animated as AnimatedRN} from 'react-native';
|
||||
import Animated, {Easing, useAnimatedRef, useAnimatedScrollHandler, useDerivedValue, useSharedValue} from 'react-native-reanimated';
|
||||
|
||||
import {storeOnboardingViewedValue} from '@actions/app/global';
|
||||
import {fetchConfigAndLicense} from '@actions/remote/systems';
|
||||
import {Screens} from '@app/constants';
|
||||
import {loginOptions} from '@app/utils/server';
|
||||
@@ -117,6 +118,9 @@ const Onboarding = ({
|
||||
},
|
||||
};
|
||||
|
||||
// mark the onboarding as already viewed
|
||||
storeOnboardingViewedValue();
|
||||
|
||||
if (goToLoginServerUrl) {
|
||||
initLogin();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user