[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 * as actions from '../actions';
|
||||
|
@ -28,26 +28,15 @@ export const initLocalSettings = function* initLocalSettings() {
|
|||
|
||||
const restore = function* restore() {
|
||||
try {
|
||||
const server = yield UserPreferences.getStringAsync(RocketChat.CURRENT_SERVER);
|
||||
let userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
||||
const { server } = appConfig;
|
||||
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
|
||||
|
||||
if (!server) {
|
||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
||||
} else if (!userId) {
|
||||
const serversDB = database.servers;
|
||||
const serversCollection = serversDB.get('servers');
|
||||
const servers = yield serversCollection.query().fetch();
|
||||
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!userId) {
|
||||
yield all([
|
||||
UserPreferences.removeItem(RocketChat.TOKEN_KEY),
|
||||
UserPreferences.removeItem(RocketChat.CURRENT_SERVER)
|
||||
]);
|
||||
yield put(serverRequest(appConfig.server));
|
||||
yield put(appStart({ root: ROOT_OUTSIDE }));
|
||||
} else {
|
||||
const serversDB = database.servers;
|
||||
|
|
Loading…
Reference in New Issue