clean up ROOT_OUTSIDE
This commit is contained in:
parent
06ca560e43
commit
c57caafaf8
|
@ -5,7 +5,7 @@ import { connect } from 'react-redux';
|
||||||
|
|
||||||
import Navigation from './lib/Navigation';
|
import Navigation from './lib/Navigation';
|
||||||
import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/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
|
// Stacks
|
||||||
import AuthLoadingView from './views/AuthLoadingView';
|
import AuthLoadingView from './views/AuthLoadingView';
|
||||||
// SetUsername Stack
|
// SetUsername Stack
|
||||||
|
@ -56,9 +56,7 @@ const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail
|
||||||
<Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}>
|
<Stack.Navigator screenOptions={{ headerShown: false, animationEnabled: false }}>
|
||||||
<>
|
<>
|
||||||
{root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null}
|
{root === ROOT_LOADING ? <Stack.Screen name='AuthLoading' component={AuthLoadingView} /> : null}
|
||||||
{root === ROOT_OUTSIDE || root === ROOT_NEW_SERVER ? (
|
{root === ROOT_NEW_SERVER ? <Stack.Screen name='OutsideStack' component={OutsideStack} /> : null}
|
||||||
<Stack.Screen name='OutsideStack' component={OutsideStack} />
|
|
||||||
) : null}
|
|
||||||
{root === ROOT_INSIDE && isMasterDetail ? (
|
{root === ROOT_INSIDE && isMasterDetail ? (
|
||||||
<Stack.Screen name='MasterDetailStack' component={MasterDetailStack} />
|
<Stack.Screen name='MasterDetailStack' component={MasterDetailStack} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { APP } from './actionsTypes';
|
import { APP } from './actionsTypes';
|
||||||
|
|
||||||
export const ROOT_OUTSIDE = 'outside';
|
|
||||||
export const ROOT_INSIDE = 'inside';
|
export const ROOT_INSIDE = 'inside';
|
||||||
export const ROOT_LOADING = 'loading';
|
export const ROOT_LOADING = 'loading';
|
||||||
export const ROOT_NEW_SERVER = 'newServer';
|
export const ROOT_NEW_SERVER = 'newServer';
|
||||||
|
|
|
@ -9,7 +9,7 @@ import RocketChat from '../lib/rocketchat';
|
||||||
import log from '../utils/log';
|
import log from '../utils/log';
|
||||||
import database from '../lib/database';
|
import database from '../lib/database';
|
||||||
import { localAuthenticate } from '../utils/localAuthentication';
|
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() {
|
export const initLocalSettings = function* initLocalSettings() {
|
||||||
const sortPreferences = yield RocketChat.getSortPreferences();
|
const sortPreferences = yield RocketChat.getSortPreferences();
|
||||||
|
@ -22,7 +22,7 @@ const restore = function* restore() {
|
||||||
let userId = yield UserPreferences.getStringAsync(`${RocketChat.TOKEN_KEY}-${server}`);
|
let userId = yield UserPreferences.getStringAsync(`${RocketChat.TOKEN_KEY}-${server}`);
|
||||||
|
|
||||||
if (!server) {
|
if (!server) {
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||||
} else if (!userId) {
|
} else if (!userId) {
|
||||||
const serversDB = database.servers;
|
const serversDB = database.servers;
|
||||||
const serversCollection = serversDB.get('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 {
|
} else {
|
||||||
const serversDB = database.servers;
|
const serversDB = database.servers;
|
||||||
const serverCollections = serversDB.get('servers');
|
const serverCollections = serversDB.get('servers');
|
||||||
|
@ -56,7 +56,7 @@ const restore = function* restore() {
|
||||||
yield put(appReady({}));
|
yield put(appReady({}));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
|
||||||
import { Q } from '@nozbe/watermelondb';
|
import { Q } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
import * as types from '../actions/actionsTypes';
|
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 { selectServerRequest, serverFinishAdd } from '../actions/server';
|
||||||
import { loginFailure, loginSuccess, logout, setUser } from '../actions/login';
|
import { loginFailure, loginSuccess, logout, setUser } from '../actions/login';
|
||||||
import { roomsRequest } from '../actions/rooms';
|
import { roomsRequest } from '../actions/rooms';
|
||||||
|
@ -204,7 +204,7 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
|
||||||
|
|
||||||
// if the user was logged out by the server
|
// if the user was logged out by the server
|
||||||
if (forcedByServer) {
|
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'));
|
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
|
||||||
yield delay(300);
|
yield delay(300);
|
||||||
Navigation.navigate('NewServerView');
|
Navigation.navigate('NewServerView');
|
||||||
|
@ -228,10 +228,10 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if there's no servers, go outside
|
// if there's no servers, go outside
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield put(appStart({ root: ROOT_NEW_SERVER }));
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import database from '../lib/database';
|
||||||
import log, { logServerVersion } from '../utils/log';
|
import log, { logServerVersion } from '../utils/log';
|
||||||
import I18n from '../i18n';
|
import I18n from '../i18n';
|
||||||
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
|
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 UserPreferences from '../lib/userPreferences';
|
||||||
import { encryptionStop } from '../actions/encryption';
|
import { encryptionStop } from '../actions/encryption';
|
||||||
import SSLPinning from '../utils/sslPinning';
|
import SSLPinning from '../utils/sslPinning';
|
||||||
|
@ -114,7 +114,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
|
||||||
yield put(appStart({ root: ROOT_INSIDE }));
|
yield put(appStart({ root: ROOT_INSIDE }));
|
||||||
} else {
|
} else {
|
||||||
yield RocketChat.connect({ server });
|
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
|
// We can't use yield here because fetch of Settings & Custom Emojis is slower
|
||||||
|
|
|
@ -5,11 +5,11 @@ import { setBadgeCount } from '../notifications/push';
|
||||||
import log from '../utils/log';
|
import log from '../utils/log';
|
||||||
import { localAuthenticate, saveLastLocalAuthenticationSession } from '../utils/localAuthentication';
|
import { localAuthenticate, saveLastLocalAuthenticationSession } from '../utils/localAuthentication';
|
||||||
import { APP_STATE } from '../actions/actionsTypes';
|
import { APP_STATE } from '../actions/actionsTypes';
|
||||||
import { ROOT_OUTSIDE } from '../actions/app';
|
import { ROOT_NEW_SERVER } from '../actions/app';
|
||||||
|
|
||||||
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
||||||
const appRoot = yield select(state => state.app.root);
|
const appRoot = yield select(state => state.app.root);
|
||||||
if (appRoot === ROOT_OUTSIDE) {
|
if (appRoot === ROOT_NEW_SERVER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const login = yield select(state => state.login);
|
const login = yield select(state => state.login);
|
||||||
|
@ -29,7 +29,7 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
|
||||||
|
|
||||||
const appHasComeBackToBackground = function* appHasComeBackToBackground() {
|
const appHasComeBackToBackground = function* appHasComeBackToBackground() {
|
||||||
const appRoot = yield select(state => state.app.root);
|
const appRoot = yield select(state => state.app.root);
|
||||||
if (appRoot === ROOT_OUTSIDE) {
|
if (appRoot === ROOT_NEW_SERVER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue