[FIX] Prevent navigation if serverInfo is undefined (#1170)

* Fix navigate when serverInfo is undefined

* Fix logs
This commit is contained in:
Djorkaeff Alexandre 2019-09-02 13:59:41 -03:00 committed by Diego Mello
parent 2515295fc6
commit 0ea0dc2aad
2 changed files with 13 additions and 12 deletions

View File

@ -86,14 +86,15 @@ const handleServerRequest = function* handleServerRequest({ server, certificate
const serverInfo = yield getServerInfo({ server });
const loginServicesLength = yield RocketChat.getLoginServices(server);
if (loginServicesLength === 0) {
Navigation.navigate('LoginView');
} else {
Navigation.navigate('LoginSignupView');
if (serverInfo) {
const loginServicesLength = yield RocketChat.getLoginServices(server);
if (loginServicesLength === 0) {
Navigation.navigate('LoginView');
} else {
Navigation.navigate('LoginSignupView');
}
yield put(selectServerRequest(server, serverInfo.version, false));
}
yield put(selectServerRequest(server, serverInfo.version, false));
} catch (e) {
yield put(serverFailure());
log(e);

View File

@ -134,8 +134,8 @@ class NewServerView extends React.Component {
const certificatePath = `${ FileSystem.documentDirectory }/${ certificate.name }`;
try {
await FileSystem.copyAsync({ from: certificate.path, to: certificatePath });
} catch (error) {
log('err_save_certificate', error);
} catch (e) {
log(e);
}
cert = {
path: this.uriToPath(certificatePath), // file:// isn't allowed by obj-C
@ -166,9 +166,9 @@ class NewServerView extends React.Component {
],
'secure-text',
);
} catch (error) {
if (!DocumentPicker.isCancel(error)) {
log('err_choose_certificate', error);
} catch (e) {
if (!DocumentPicker.isCancel(e)) {
log(e);
}
}
}