clean up ROOT_OUTSIDE

This commit is contained in:
Reinaldo Neto 2021-09-17 12:17:56 -03:00
parent 06ca560e43
commit c57caafaf8
6 changed files with 15 additions and 18 deletions

View File

@ -5,7 +5,7 @@ import { connect } from 'react-redux';
import Navigation from './lib/Navigation';
import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_SET_USERNAME } from './actions/app';
// Stacks
import AuthLoadingView from './views/AuthLoadingView';
// SetUsername Stack
@ -56,9 +56,7 @@ const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail
<Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}>
<>
{root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null}
{root === ROOT_OUTSIDE || root === ROOT_NEW_SERVER ? (
<Stack.Screen name='OutsideStack' component={OutsideStack} />
) : null}
{root === ROOT_NEW_SERVER ? <Stack.Screen name='OutsideStack' component={OutsideStack} /> : null}
{root === ROOT_INSIDE && isMasterDetail ? (
<Stack.Screen name='MasterDetailStack' component={MasterDetailStack} />
) : null}

View File

@ -1,6 +1,5 @@
import { APP } from './actionsTypes';
export const ROOT_OUTSIDE = 'outside';
export const ROOT_INSIDE = 'inside';
export const ROOT_LOADING = 'loading';
export const ROOT_NEW_SERVER = 'newServer';

View File

@ -9,7 +9,7 @@ import RocketChat from '../lib/rocketchat';
import log from '../utils/log';
import database from '../lib/database';
import { localAuthenticate } from '../utils/localAuthentication';
import { ROOT_OUTSIDE, appReady, appStart } from '../actions/app';
import { ROOT_NEW_SERVER, appReady, appStart } from '../actions/app';
export const initLocalSettings = function* initLocalSettings() {
const sortPreferences = yield RocketChat.getSortPreferences();
@ -22,7 +22,7 @@ const restore = function* restore() {
let userId = yield UserPreferences.getStringAsync(`${RocketChat.TOKEN_KEY}-${server}`);
if (!server) {
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
} else if (!userId) {
const serversDB = database.servers;
const serversCollection = serversDB.get('servers');
@ -38,7 +38,7 @@ const restore = function* restore() {
}
}
}
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
} else {
const serversDB = database.servers;
const serverCollections = serversDB.get('servers');
@ -56,7 +56,7 @@ const restore = function* restore() {
yield put(appReady({}));
} catch (e) {
log(e);
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
}
};

View File

@ -3,7 +3,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
import { Q } from '@nozbe/watermelondb';
import * as types from '../actions/actionsTypes';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME, appStart } from '../actions/app';
import { ROOT_INSIDE, ROOT_LOADING, ROOT_NEW_SERVER, ROOT_SET_USERNAME, appStart } from '../actions/app';
import { selectServerRequest, serverFinishAdd } from '../actions/server';
import { loginFailure, loginSuccess, logout, setUser } from '../actions/login';
import { roomsRequest } from '../actions/rooms';
@ -204,7 +204,7 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
// if the user was logged out by the server
if (forcedByServer) {
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
yield delay(300);
Navigation.navigate('NewServerView');
@ -228,10 +228,10 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
}
}
// if there's no servers, go outside
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
}
} catch (e) {
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
log(e);
}
}

View File

@ -15,7 +15,7 @@ import database from '../lib/database';
import log, { logServerVersion } from '../utils/log';
import I18n from '../i18n';
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
import { ROOT_INSIDE, ROOT_OUTSIDE, appStart } from '../actions/app';
import { ROOT_INSIDE, ROOT_NEW_SERVER, appStart } from '../actions/app';
import UserPreferences from '../lib/userPreferences';
import { encryptionStop } from '../actions/encryption';
import SSLPinning from '../utils/sslPinning';
@ -114,7 +114,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
yield put(appStart({ root: ROOT_INSIDE }));
} else {
yield RocketChat.connect({ server });
yield put(appStart({ root: ROOT_OUTSIDE }));
yield put(appStart({ root: ROOT_NEW_SERVER }));
}
// We can't use yield here because fetch of Settings & Custom Emojis is slower

View File

@ -5,11 +5,11 @@ import { setBadgeCount } from '../notifications/push';
import log from '../utils/log';
import { localAuthenticate, saveLastLocalAuthenticationSession } from '../utils/localAuthentication';
import { APP_STATE } from '../actions/actionsTypes';
import { ROOT_OUTSIDE } from '../actions/app';
import { ROOT_NEW_SERVER } from '../actions/app';
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
const appRoot = yield select(state => state.app.root);
if (appRoot === ROOT_OUTSIDE) {
if (appRoot === ROOT_NEW_SERVER) {
return;
}
const login = yield select(state => state.login);
@ -29,7 +29,7 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
const appHasComeBackToBackground = function* appHasComeBackToBackground() {
const appRoot = yield select(state => state.app.root);
if (appRoot === ROOT_OUTSIDE) {
if (appRoot === ROOT_NEW_SERVER) {
return;
}
try {