Skip to content

Commit

Permalink
#1552 | getPreviousSettings after resetting Locale which is removed t…
Browse files Browse the repository at this point in the history
…o avoid issues with re-login with different org user
  • Loading branch information
himeshr committed Dec 6, 2024
1 parent 7cef7ec commit 2b63460
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion packages/openchs-android/src/service/BackupRestoreRealm.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default class BackupRestoreRealmService extends BaseService {
let entitySyncStatusService = this.getService(EntitySyncStatusService);
let downloadedFile = `${fs.DocumentDirectoryPath}/${General.randomUUID()}.zip`;
let downloadedUncompressedDir = `${fs.DocumentDirectoryPath}/${General.randomUUID()}`;
const prevSettings = settingsService.getSettings().clone();
const prevSettings = this.getPreviousSettings(settingsService);
const prevUserInfo = UserInfo.fromResource({username: prevSettings.userId, organisationName: 'dummy', name: prevSettings.userId});

General.logInfo("BackupRestoreRealm", `To be downloaded file: ${downloadedFile}, Unzipped directory: ${downloadedUncompressedDir}, Realm file: ${REALM_FILE_FULL_PATH}`);
Expand Down Expand Up @@ -195,6 +195,12 @@ export default class BackupRestoreRealmService extends BaseService {
});
}

getPreviousSettings(settingsService) {
const prevSettings = settingsService.getSettings().clone();
prevSettings.locale = null;
return prevSettings;
}

_deleteUserInfoAndIdAssignment() {
this._deleteAndResetSync(UserInfo.schema.name);
this._deleteAndResetSync(IdentifierAssignment.schema.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,14 @@ class RuleEvaluationService extends BaseService {
ruleTypeValue = entity;
return rule.fn.exec(entity, context, entityContext)
} else {
General.logDebug("Rule-to-run", `Rule context and config: ${JSONStringify(context)}, ${JSONStringify(config)}, ${JSONStringify(entityContext)}`);
General.logDebug("Rule-to-run", `Rule function: ${rule.name}, uuid: ${rule.uuid}, ${JSONStringify(rule.fn)}`);
return _.isNil(context) ?
rule.fn.exec(entity, ruleTypeValue, config, entityContext) :
rule.fn.exec(entity, ruleTypeValue, context, config, entityContext);
}
} catch (error) {
General.logDebug("Rule-Failure", `Rule failed: ${rule.name}, uuid: ${rule.uuid}`);
General.logDebug("Rule-Failure", `Rule failed: ${rule.name}, uuid: ${rule.uuid}`, error.message);
this.saveFailedRules(error, rule.uuid, this.getIndividualUUID(entity, entityName),
'Decision', rule.uuid, entityName, entity.uuid);
return ruleTypeValue;
Expand Down

0 comments on commit 2b63460

Please sign in to comment.