[FIX] White screen on start on single-server (#3329)
This commit is contained in:
parent
8ee9a8ab75
commit
ea46ae8469
|
@ -1,4 +1,4 @@
|
||||||
import { put, takeLatest } from 'redux-saga/effects';
|
import { put, takeLatest, all } from 'redux-saga/effects';
|
||||||
import RNBootSplash from 'react-native-bootsplash';
|
import RNBootSplash from 'react-native-bootsplash';
|
||||||
|
|
||||||
// import * as actions from '../actions';
|
// import * as actions from '../actions';
|
||||||
|
@ -28,26 +28,15 @@ export const initLocalSettings = function* initLocalSettings() {
|
||||||
|
|
||||||
const restore = function* restore() {
|
const restore = function* restore() {
|
||||||
try {
|
try {
|
||||||
const server = yield UserPreferences.getStringAsync(RocketChat.CURRENT_SERVER);
|
const { server } = appConfig;
|
||||||
let userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
||||||
|
|
||||||
if (!server) {
|
if (!userId) {
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield all([
|
||||||
} else if (!userId) {
|
UserPreferences.removeItem(RocketChat.TOKEN_KEY),
|
||||||
const serversDB = database.servers;
|
UserPreferences.removeItem(RocketChat.CURRENT_SERVER)
|
||||||
const serversCollection = serversDB.get('servers');
|
]);
|
||||||
const servers = yield serversCollection.query().fetch();
|
yield put(serverRequest(appConfig.server));
|
||||||
|
|
||||||
// Check if there're other logged in servers and picks first one
|
|
||||||
if (servers.length > 0) {
|
|
||||||
for (let i = 0; i < servers.length; i += 1) {
|
|
||||||
const newServer = servers[i].id;
|
|
||||||
userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ newServer }`);
|
|
||||||
if (userId) {
|
|
||||||
return yield put(selectServerRequest(newServer));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
yield put(appStart({ root: ROOT_OUTSIDE }));
|
||||||
} else {
|
} else {
|
||||||
const serversDB = database.servers;
|
const serversDB = database.servers;
|
||||||
|
|
Loading…
Reference in New Issue