Fix network state
This commit is contained in:
parent
bd1d2be557
commit
9633d8c5cb
4 changed files with 27 additions and 9 deletions
|
|
@ -30,10 +30,7 @@ class SyncController {
|
|||
}
|
||||
|
||||
async checkConnection() {
|
||||
NetInfo.fetch().then(state => {
|
||||
return state.isConnected;
|
||||
});
|
||||
return false;
|
||||
return NetInfo.fetch();
|
||||
}
|
||||
|
||||
async getVersion() {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,14 @@ class InstallScreen extends React.Component {
|
|||
async install() {
|
||||
let url = this.state.url;
|
||||
Setting.upsert({ key: 'bo_url', value: url });
|
||||
if (!SyncController.checkConnection()) {
|
||||
const isConnected = await SyncController.checkConnection().then(state => {
|
||||
//console.log(state.isConnected)
|
||||
return state.isConnected
|
||||
}).catch(error => {
|
||||
//console.log(error);
|
||||
return false;
|
||||
});
|
||||
if (!isConnected) {
|
||||
Alert.alert(
|
||||
i18n.t('global.warning'),
|
||||
i18n.t('error.must_be_connected_internet_sync')
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class LoginScreen extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
login(login, password) {
|
||||
async login(login, password) {
|
||||
if (login === '' || password === '') {
|
||||
Alert.alert(i18n.t("global.warning"), i18n.t('error.must_fill_login_fields'));
|
||||
return;
|
||||
|
|
@ -102,11 +102,18 @@ class LoginScreen extends React.Component {
|
|||
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
||||
return;
|
||||
}
|
||||
const isConnected = await SyncController.checkConnection().then(state => {
|
||||
//console.log(state.isConnected)
|
||||
return state.isConnected
|
||||
}).catch(error => {
|
||||
//console.log(error);
|
||||
return false;
|
||||
});
|
||||
const lastUser = Setting.get('lastUser');
|
||||
// Si on est sur une installation
|
||||
if (lastUser === false || lastUser == undefined) {
|
||||
// Si la tablette est connectée à internet pour forcer la synchro
|
||||
if (!SyncController.checkConnection()) {
|
||||
if (!isConnected) {
|
||||
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
||||
return;
|
||||
}
|
||||
|
|
@ -124,7 +131,7 @@ class LoginScreen extends React.Component {
|
|||
return;
|
||||
}
|
||||
// Si la tablette est connectée à internet pour forcer la synchro
|
||||
if (!SyncController.checkConnection()) {
|
||||
if (!isConnected) {
|
||||
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,14 @@ class SyncScreen extends React.Component {
|
|||
}
|
||||
|
||||
async sync() {
|
||||
if (!SyncController.checkConnection()) {
|
||||
const isConnected = await SyncController.checkConnection().then(state => {
|
||||
//console.log(state.isConnected)
|
||||
return state.isConnected
|
||||
}).catch(error => {
|
||||
//console.log(error);
|
||||
return false;
|
||||
});
|
||||
if (!isConnected) {
|
||||
Alert.alert(
|
||||
i18n.t('global.warning'),
|
||||
i18n.t('error.must_be_connected_internet_sync')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue