diff --git a/app/AppContainer.tsx b/app/AppContainer.tsx
index b73aaf8e3..0526d3a14 100644
--- a/app/AppContainer.tsx
+++ b/app/AppContainer.tsx
@@ -6,7 +6,7 @@ import { connect } from 'react-redux';
import { SetUsernameStackParamList, StackParamList } from './navigationTypes';
import Navigation from './lib/Navigation';
import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation';
-import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app';
+import { RootEnum } from './definitions';
// Stacks
import AuthLoadingView from './views/AuthLoadingView';
// SetUsername Stack
@@ -56,13 +56,13 @@ const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail
}}>
<>
- {root === ROOT_LOADING ? : null}
- {root === ROOT_OUTSIDE ? : null}
- {root === ROOT_INSIDE && isMasterDetail ? (
+ {root === RootEnum.ROOT_LOADING ? : null}
+ {root === RootEnum.ROOT_OUTSIDE ? : null}
+ {root === RootEnum.ROOT_INSIDE && isMasterDetail ? (
) : null}
- {root === ROOT_INSIDE && !isMasterDetail ? : null}
- {root === ROOT_SET_USERNAME ? : null}
+ {root === RootEnum.ROOT_INSIDE && !isMasterDetail ? : null}
+ {root === RootEnum.ROOT_SET_USERNAME ? : null}
>
diff --git a/app/actions/app.ts b/app/actions/app.ts
index 5fdb312ef..e1a6b04c2 100644
--- a/app/actions/app.ts
+++ b/app/actions/app.ts
@@ -3,11 +3,6 @@ import { Action } from 'redux';
import { RootEnum } from '../definitions';
import { APP } from './actionsTypes';
-export const ROOT_OUTSIDE = 'outside';
-export const ROOT_INSIDE = 'inside';
-export const ROOT_LOADING = 'loading';
-export const ROOT_SET_USERNAME = 'setUsername';
-
interface IAppStart extends Action {
root: RootEnum;
text?: string;
diff --git a/app/sagas/deepLinking.js b/app/sagas/deepLinking.js
index 240771b3e..900e6a145 100644
--- a/app/sagas/deepLinking.js
+++ b/app/sagas/deepLinking.js
@@ -8,11 +8,12 @@ import { inviteLinksRequest, inviteLinksSetToken } from '../actions/inviteLinks'
import database from '../lib/database';
import RocketChat from '../lib/rocketchat';
import EventEmitter from '../utils/events';
-import { ROOT_INSIDE, ROOT_OUTSIDE, appInit, appStart } from '../actions/app';
+import { appInit, appStart } from '../actions/app';
import { localAuthenticate } from '../utils/localAuthentication';
import { goRoom } from '../utils/goRoom';
import { loginRequest } from '../actions/login';
import log from '../utils/log';
+import { RootEnum } from '../definitions';
const roomTypes = {
channel: 'c',
@@ -41,7 +42,7 @@ const popToRoot = function popToRoot({ isMasterDetail }) {
};
const navigate = function* navigate({ params }) {
- yield put(appStart({ root: ROOT_INSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_INSIDE }));
if (params.path || params.rid) {
let type;
let name;
@@ -192,7 +193,7 @@ const handleOpen = function* handleOpen({ params }) {
yield fallbackNavigation();
return;
}
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
yield put(serverInitAdd(server));
yield delay(1000);
EventEmitter.emit('NewServer', { server: host });
diff --git a/app/sagas/init.js b/app/sagas/init.js
index af42c4faa..3d7fbd9dc 100644
--- a/app/sagas/init.js
+++ b/app/sagas/init.js
@@ -9,7 +9,8 @@ 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 { appReady, appStart } from '../actions/app';
+import { RootEnum } from '../definitions';
export const initLocalSettings = function* initLocalSettings() {
const sortPreferences = yield RocketChat.getSortPreferences();
@@ -22,7 +23,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: RootEnum.ROOT_OUTSIDE }));
} else if (!userId) {
const serversDB = database.servers;
const serversCollection = serversDB.get('servers');
@@ -38,7 +39,7 @@ const restore = function* restore() {
}
}
}
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
} else {
const serversDB = database.servers;
const serverCollections = serversDB.get('servers');
@@ -56,7 +57,7 @@ const restore = function* restore() {
yield put(appReady({}));
} catch (e) {
log(e);
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
}
};
diff --git a/app/sagas/login.js b/app/sagas/login.js
index 1d8f688f2..26435ad59 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 { appStart } from '../actions/app';
import { selectServerRequest, serverFinishAdd } from '../actions/server';
import { loginFailure, loginSuccess, logout, setUser } from '../actions/login';
import { roomsRequest } from '../actions/rooms';
@@ -20,6 +20,7 @@ import { encryptionInit, encryptionStop } from '../actions/encryption';
import UserPreferences from '../lib/userPreferences';
import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry';
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
+import { RootEnum } from '../definitions';
const getServer = state => state.server.server;
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
@@ -38,7 +39,7 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE
if (!result.username) {
yield put(serverFinishAdd());
yield put(setUser(result));
- yield put(appStart({ root: ROOT_SET_USERNAME }));
+ yield put(appStart({ root: RootEnum.ROOT_SET_USERNAME }));
} else {
const server = yield select(getServer);
yield localAuthenticate(server);
@@ -167,7 +168,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) {
yield put(setUser(user));
EventEmitter.emit('connected');
- yield put(appStart({ root: ROOT_INSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_INSIDE }));
const inviteLinkToken = yield select(state => state.inviteLinks.token);
if (inviteLinkToken) {
yield put(inviteLinksRequest(inviteLinkToken));
@@ -179,7 +180,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) {
const handleLogout = function* handleLogout({ forcedByServer }) {
yield put(encryptionStop());
- yield put(appStart({ root: ROOT_LOADING, text: I18n.t('Logging_out') }));
+ yield put(appStart({ root: RootEnum.ROOT_LOADING, text: I18n.t('Logging_out') }));
const server = yield select(getServer);
if (server) {
try {
@@ -187,7 +188,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: RootEnum.ROOT_OUTSIDE }));
showErrorAlert(I18n.t('Logged_out_by_server'), I18n.t('Oops'));
yield delay(300);
EventEmitter.emit('NewServer', { server });
@@ -209,10 +210,10 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
}
}
// if there's no servers, go outside
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
}
} catch (e) {
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
log(e);
}
}
diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js
index 5aacd2b11..26131a31c 100644
--- a/app/sagas/selectServer.js
+++ b/app/sagas/selectServer.js
@@ -15,11 +15,12 @@ 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 { appStart } from '../actions/app';
import UserPreferences from '../lib/userPreferences';
import { encryptionStop } from '../actions/encryption';
import SSLPinning from '../utils/sslPinning';
import { inquiryReset } from '../ee/omnichannel/actions/inquiry';
+import { RootEnum } from '../definitions';
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
try {
@@ -111,10 +112,10 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
yield put(clearSettings());
yield RocketChat.connect({ server, user, logoutOnError: true });
yield put(setUser(user));
- yield put(appStart({ root: ROOT_INSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_INSIDE }));
} else {
yield RocketChat.connect({ server });
- yield put(appStart({ root: ROOT_OUTSIDE }));
+ yield put(appStart({ root: RootEnum.ROOT_OUTSIDE }));
}
// 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..8f122b4d8 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 { RootEnum } from '../definitions';
const appHasComeBackToForeground = function* appHasComeBackToForeground() {
const appRoot = yield select(state => state.app.root);
- if (appRoot === ROOT_OUTSIDE) {
+ if (appRoot === RootEnum.ROOT_OUTSIDE) {
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 === RootEnum.ROOT_OUTSIDE) {
return;
}
try {
diff --git a/app/views/LanguageView/index.tsx b/app/views/LanguageView/index.tsx
index 955572e24..3f116566c 100644
--- a/app/views/LanguageView/index.tsx
+++ b/app/views/LanguageView/index.tsx
@@ -13,10 +13,11 @@ import StatusBar from '../../containers/StatusBar';
import * as List from '../../containers/List';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
-import { ROOT_INSIDE, ROOT_LOADING, appStart as appStartAction } from '../../actions/app';
+import { appStart as appStartAction } from '../../actions/app';
import { getUserSelector } from '../../selectors/login';
import database from '../../lib/database';
import SafeAreaView from '../../containers/SafeAreaView';
+import { RootEnum } from '../../definitions';
interface ILanguageViewProps {
user: {
@@ -73,7 +74,7 @@ class LanguageView extends React.Component setTimeout(resolve, 300))]);
@@ -81,7 +82,7 @@ class LanguageView extends React.Component {
const { appStart, initAdd } = this.props;
batch(() => {
- appStart({ root: ROOT_OUTSIDE });
+ appStart({ root: RootEnum.ROOT_OUTSIDE });
initAdd(previousServer);
});
};
diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js
index 518e10c48..55e2b1f8b 100644
--- a/app/views/RoomsListView/index.js
+++ b/app/views/RoomsListView/index.js
@@ -50,6 +50,8 @@ import { E2E_BANNER_TYPE } from '../../lib/encryption/constants';
import { getInquiryQueueSelector } from '../../ee/omnichannel/selectors/inquiry';
import { changeLivechatStatus, isOmnichannelStatusAvailable } from '../../ee/omnichannel/lib';
import { DISPLAY_MODE_CONDENSED } from '../../constants/constantDisplayMode';
+import { RootEnum } from '../../definitions';
+
import styles from './styles';
import ServerDropdown from './ServerDropdown';
import ListHeader from './ListHeader';
@@ -862,7 +864,7 @@ class RoomsListView extends React.Component {
}
} else if (handleCommandAddNewServer(event)) {
batch(() => {
- appStart({ root: ROOT_OUTSIDE });
+ appStart({ root: RootEnum.ROOT_OUTSIDE });
initAdd(server);
});
}
diff --git a/app/views/SettingsView/index.tsx b/app/views/SettingsView/index.tsx
index edad2822e..806dcfd65 100644
--- a/app/views/SettingsView/index.tsx
+++ b/app/views/SettingsView/index.tsx
@@ -23,12 +23,13 @@ import { withTheme } from '../../theme';
import SidebarView from '../SidebarView';
import { LISTENER } from '../../containers/Toast';
import EventEmitter from '../../utils/events';
-import { ROOT_LOADING, appStart as appStartAction } from '../../actions/app';
+import { appStart as appStartAction } from '../../actions/app';
import { onReviewPress } from '../../utils/review';
import SafeAreaView from '../../containers/SafeAreaView';
import database from '../../lib/database';
import { isFDroidBuild } from '../../constants/environment';
import { getUserSelector } from '../../selectors/login';
+import { RootEnum } from '../../definitions';
interface ISettingsViewProps {
navigation: StackNavigationProp;
@@ -108,7 +109,7 @@ class SettingsView extends React.Component {
appStart,
selectServerRequest
} = this.props;
- appStart({ root: ROOT_LOADING, text: I18n.t('Clear_cache_loading') });
+ appStart({ root: RootEnum.ROOT_LOADING, text: I18n.t('Clear_cache_loading') });
await RocketChat.clearCache({ server });
await FastImage.clearMemoryCache();
await FastImage.clearDiskCache();