From c57caafaf8ac5256f871a2cf3115d2a09c0eaa86 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 17 Sep 2021 12:17:56 -0300 Subject: [PATCH] clean up ROOT_OUTSIDE --- app/AppContainer.tsx | 6 ++---- app/actions/app.js | 1 - app/sagas/init.js | 8 ++++---- app/sagas/login.js | 8 ++++---- app/sagas/selectServer.js | 4 ++-- app/sagas/state.js | 6 +++--- 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/app/AppContainer.tsx b/app/AppContainer.tsx index 00d851010..c87572feb 100644 --- a/app/AppContainer.tsx +++ b/app/AppContainer.tsx @@ -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 <> {root === ROOT_LOADING ? : null} - {root === ROOT_OUTSIDE || root === ROOT_NEW_SERVER ? ( - - ) : null} + {root === ROOT_NEW_SERVER ? : null} {root === ROOT_INSIDE && isMasterDetail ? ( ) : null} diff --git a/app/actions/app.js b/app/actions/app.js index 9ced0c6c2..dc3d205c5 100644 --- a/app/actions/app.js +++ b/app/actions/app.js @@ -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'; diff --git a/app/sagas/init.js b/app/sagas/init.js index af42c4faa..7762e3177 100644 --- a/app/sagas/init.js +++ b/app/sagas/init.js @@ -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 })); } }; diff --git a/app/sagas/login.js b/app/sagas/login.js index 516599c3d..592791233 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -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); } } diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index 5aacd2b11..c26625d94 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -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 diff --git a/app/sagas/state.js b/app/sagas/state.js index b9afeb4dd..fae50dcfe 100644 --- a/app/sagas/state.js +++ b/app/sagas/state.js @@ -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 {