diff --git a/packages/openchs-android/index.android.js b/packages/openchs-android/index.android.js index b0cb1733a..a86473e10 100644 --- a/packages/openchs-android/index.android.js +++ b/packages/openchs-android/index.android.js @@ -1,5 +1,6 @@ /* @flow */ import {AppRegistry} from 'react-native'; +// import App from './integrationTest/RealmIssuesApp'; // import App from "./integrationTest/IntegrationTestApp"; import App from "./src/Avni"; AppRegistry.registerComponent('Avni', () => App); diff --git a/packages/openchs-android/src/action/LoginActions.js b/packages/openchs-android/src/action/LoginActions.js index a22871936..18b7ea1f0 100644 --- a/packages/openchs-android/src/action/LoginActions.js +++ b/packages/openchs-android/src/action/LoginActions.js @@ -8,6 +8,15 @@ import BackupRestoreRealmService from "../service/BackupRestoreRealm"; import SettingsService from "../service/SettingsService"; import { IDP_PROVIDERS } from "../model/IdpProviders"; +function restoreDump(context, action, source, successCb) { + const restoreService = context.get(BackupRestoreRealmService); + restoreService.restore((percentProgress, message, failed = false, failureMessage) => { + if (failed) action.checkForRetry(failureMessage, source); + else if (percentProgress === 100) successCb(source); + else action.onLoginProgress(percentProgress, message); + }); +} + class LoginActions { static getInitialState() { return { @@ -82,21 +91,12 @@ class LoginActions { const doRestoreDump = backupRestoreRealmService.isDatabaseNeverSynced(); General.logInfo("LoginActions", `Dump restore can be done = ${doRestoreDump}`); if (doRestoreDump) { - LoginActions.restoreDump(context, action, source, successCb); + restoreDump(context, action, source, successCb); } else { successCb(source); } } - static restoreDump(context, action, source, successCb) { - let restoreService = context.get(BackupRestoreRealmService); - restoreService.restore((percentProgress, message, failed = false, failureMessage) => { - if (failed) action.checkForRetry(failureMessage, source); - else if (percentProgress === 100) successCb(source); - else action.onLoginProgress(percentProgress, message); - }); - } - static onStateChange(state, action) { return _.assignIn({}, state, action.newState); } @@ -117,14 +117,16 @@ class LoginActions { static onDumpRestoreRetry(state, action, context) { let newState = _.assignIn({}, state, {percentProgress: 0}); - LoginActions.restoreDump(context, action, action.source); + //restore dump calls dispatch internally + setTimeout(() => { + restoreDump(context, action, action.source); + }, 1); return newState; } static onUserToggleIdp(state) { return _.assignIn({}, state, {userSelectedIdp: state.userSelectedIdp === IDP_PROVIDERS.COGNITO ? IDP_PROVIDERS.KEYCLOAK: IDP_PROVIDERS.COGNITO}); } - } const LoginActionsNames = { diff --git a/packages/openchs-android/src/views/LoginView.js b/packages/openchs-android/src/views/LoginView.js index 554172be3..eb906082a 100644 --- a/packages/openchs-android/src/views/LoginView.js +++ b/packages/openchs-android/src/views/LoginView.js @@ -360,7 +360,7 @@ class LoginView extends AbstractComponent { } onLoginProgress(percentProgress, message) { - General.logDebug('LoginView', message); + General.logDebug('LoginView', `onLoginProgress ${message}`); this.dispatchAction(Actions.ON_DUMP_RESTORING, {percentProgress: percentProgress, message: message}); }