Skip to content

Commit

Permalink
Merge branch '5.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Oct 23, 2023
2 parents 22c6f1d + 758aa0b commit 26c646d
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 48 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ release_prod_without_clean: as_prod release upload-release-sourcemap
release_prod_dev_without_clean: as_prod_dev release
release_prod: renew_env release_prod_without_clean

release_prod_dev_without_clean: as_prod_dev release upload-release-sourcemap

bundle_release_prod_without_clean: as_prod bundle_release upload-release-sourcemap
bundle_release_prod: renew_env bundle_release_prod_without_clean

Expand Down Expand Up @@ -374,6 +376,7 @@ upload-prod-apk-unsigned: ; $(call _upload_apk,prod)
upload-staging-apk: ; $(call _upload_apk,staging)
upload-prerelease-apk: ; $(call _upload_apk,prerelease)
upload-uat-apk: ; $(call _upload_apk,uat)
upload-prod_dev-apk: ; $(call _upload_apk,prod_dev)

define _inpremise_upload_prod_apk
@aws s3 cp --acl public-read packages/openchs-android/android/app/build/outputs/apk/release/app-release.apk s3://samanvay/openchs/$(orgname)/apks/prod-$(sha)-$(dat).apk;
Expand Down
44 changes: 22 additions & 22 deletions packages/openchs-android/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/openchs-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
],
"dependencies": {
"@react-native-async-storage/async-storage": "^1.18.2",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-clipboard/clipboard": "^1.12.1",
"@react-native-community/datetimepicker": "^6.5.0",
"@react-native-community/netinfo": "9.3.0",
"@react-native-community/progress-bar-android": "^1.0.5",
Expand All @@ -57,7 +57,7 @@
"lodash": "4.17.21",
"moment": "2.29.4",
"native-base": "3.4.9",
"openchs-models": "1.30.75",
"openchs-models": "1.30.79",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-native": "0.72.3",
Expand Down
29 changes: 18 additions & 11 deletions packages/openchs-android/src/service/SubjectMigrationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ class SubjectMigrationService extends BaseService {
}

migrateSubjects(notifyProgress) {
if (this.getCount(Individual.schema.name) === 0)
return;

const length = this.findAll().filtered('hasMigrated = false').length;
const individualCount = this.getCount(Individual.schema.name);
const nothingToMigrate = individualCount === 0;
for (let i = 0; i < length; i++) {
const subjectMigration = this.findAll().filtered('hasMigrated = false limit(1)')[0];
const handle = setTimeout(() => {
if (nothingToMigrate) {
this.markMigrated(subjectMigration);
} else {
this.migrateSubjectIfRequired(subjectMigration);
}
const handle = setTimeout(() => {
notifyProgress("SubjectMigration", length, i);
clearTimeout(handle);
}, 1);
}, 50);
}
}

Expand Down Expand Up @@ -195,14 +198,14 @@ class SubjectMigrationService extends BaseService {
const addressLevelService = this.getService(AddressLevelService);
const userInfoService = this.getService(UserInfoService);
const subjectType = this.getService(SubjectTypeService).findByUUID(subjectMigration.subjectTypeUUID);
const syncConcept1Values = userInfoService.getSyncConcept1Values(subjectType);
const syncConcept2Values = userInfoService.getSyncConcept2Values(subjectType);
const userSyncConcept1Values = userInfoService.getSyncConcept1Values(subjectType);
const userSyncConcept2Values = userInfoService.getSyncConcept2Values(subjectType);
const oldAddressExists = addressLevelService.existsByUuid(subjectMigration.oldAddressLevelUUID);
const newAddressExists = addressLevelService.existsByUuid(subjectMigration.newAddressLevelUUID);
const oldSyncConcept1ValueExists = _.includes(syncConcept1Values, subjectMigration.oldSyncConcept1Value);
const newSyncConcept1ValueExists =_.includes(syncConcept1Values, subjectMigration.newSyncConcept1Value);
const oldSyncConcept2ValueExists = _.includes(syncConcept2Values, subjectMigration.oldSyncConcept2Value);
const newSyncConcept2ValueExists = _.includes(syncConcept2Values, subjectMigration.newSyncConcept2Value);
const oldSyncConcept1ValueExists = _.includes(userSyncConcept1Values, subjectMigration.oldSyncConcept1Value);
const newSyncConcept1ValueExists =_.includes(userSyncConcept1Values, subjectMigration.newSyncConcept1Value);
const oldSyncConcept2ValueExists = _.includes(userSyncConcept2Values, subjectMigration.oldSyncConcept2Value);
const newSyncConcept2ValueExists = _.includes(userSyncConcept2Values, subjectMigration.newSyncConcept2Value);

if ((oldAddressExists && !newAddressExists) ||
(oldSyncConcept1ValueExists && !newSyncConcept1ValueExists) ||
Expand All @@ -211,6 +214,10 @@ class SubjectMigrationService extends BaseService {
this.removeEntitiesFor(subjectMigration);
}

this.markMigrated(subjectMigration);
}

markMigrated(subjectMigration) {
const db = this.db;
db.write(() => {
subjectMigration.hasMigrated = true;
Expand Down
10 changes: 6 additions & 4 deletions packages/openchs-android/src/service/SyncService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BaseService from "./BaseService";
import EntityService from "./EntityService";
import EntitySyncStatusService from "./EntitySyncStatusService";
import SettingsService from "./SettingsService";
import {EntityMetaData, EntitySyncStatus, RuleFailureTelemetry, SyncTelemetry, Individual} from 'openchs-models';
import {EntityMetaData, EntitySyncStatus, RuleFailureTelemetry, SyncTelemetry, Individual, UserInfo} from 'openchs-models';
import EntityQueueService from "./EntityQueueService";
import MessageService from "./MessageService";
import RuleEvaluationService from "./RuleEvaluationService";
Expand Down Expand Up @@ -180,16 +180,18 @@ class SyncService extends BaseService {

const entitiesWithoutSubjectMigrationAndResetSync = _.filter(allEntitiesMetaData, ({entityName}) => !_.includes(['ResetSync', 'SubjectMigration'], entityName));
const filteredMetadata = _.filter(entitiesWithoutSubjectMigrationAndResetSync, ({entityName}) => _.find(syncDetails, sd => sd.entityName === entityName));
const filteredRefData = this.getMetadataByType(filteredMetadata, "reference");
const referenceEntityMetadata = this.getMetadataByType(filteredMetadata, "reference");
const filteredTxData = this.getMetadataByType(filteredMetadata, "tx");
const userInfoData = _.filter(filteredMetadata, ({entityName}) => entityName === "UserInfo");
const subjectMigrationMetadata = _.filter(allEntitiesMetaData, ({entityName}) => entityName === "SubjectMigration");
const currentVersionEntitySyncDetails = this.retainEntitiesPresentInCurrentVersion(syncDetails, allEntitiesMetaData);
General.logDebug("SyncService", `Entities to sync ${_.map(currentVersionEntitySyncDetails, ({entityName, entityTypeUuid}) => [entityName, entityTypeUuid])}`);
this.entitySyncStatusService.updateAsPerSyncDetails(currentVersionEntitySyncDetails);

let syncDetailsWithPrivileges;
return Promise.resolve(statusMessageCallBack("downloadForms"))
.then(() => this.getRefData(filteredRefData, onProgressPerEntity, now))
.then(() => this.getTxData(userInfoData, onProgressPerEntity, syncDetails, endDateTime))
.then(() => this.getRefData(referenceEntityMetadata, onProgressPerEntity, now, endDateTime))
.then(() => this.getService(EncryptionService).encryptOrDecryptDbIfRequired())
.then(() => syncDetailsWithPrivileges = this.updateAsPerNewPrivilege(allEntitiesMetaData, updateProgressSteps, currentVersionEntitySyncDetails))
.then(() => statusMessageCallBack("downloadNewDataFromServer"))
Expand Down Expand Up @@ -308,7 +310,7 @@ class SyncService extends BaseService {
this.getService(UserSubjectAssignmentService).deleteUnassignedSubjectsAndDependents(entities);
}

General.logDebugTemp("SyncService", `${entityMetaData.entityName} ${entityMetaData.syncStatus.entityTypeUuid}`);
General.logDebug("SyncService", `Syncing - ${entityMetaData.entityName} with subType: ${entityMetaData.syncStatus.entityTypeUuid}`);
const currentEntitySyncStatus = this.entitySyncStatusService.get(entityMetaData.entityName, entityMetaData.syncStatus.entityTypeUuid);
const entitySyncStatus = new EntitySyncStatus();
entitySyncStatus.entityName = entityMetaData.entityName;
Expand Down
1 change: 0 additions & 1 deletion packages/openchs-android/src/utility/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {Concept, Duration, Observation} from 'avni-models';
import _ from 'lodash';
import moment from "moment";
import EnvironmentConfig from "../framework/EnvironmentConfig";
import Clipboard from '@react-native-community/clipboard';

let currentLogLevel;

Expand Down
21 changes: 14 additions & 7 deletions packages/openchs-android/src/views/common/SecureTextInput.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import React, {useState} from "react";
import {TextInput} from "react-native";
import General from "../../utility/General";
import Clipboard from "@react-native-clipboard/clipboard";
import _ from "lodash";

export const SecureTextInput = (props) => {
const [inputTextSelection, setInputTextSelection] = useState({ start: 0, end: 0 });
const onSelectionChange = ({ nativeEvent: { selection } }) => {
setInputTextSelection({ start: selection.end, end: selection.end } );
};

const clearClipboard = async () => {
const clipboardText = await Clipboard.getString()
if (!_.isEmpty(clipboardText)) {
Clipboard.setString('');
}
}

return (
<TextInput
{...props}
contextMenuHidden={true}
onFocus={() => {
General.clearClipboard();
}}
onBlur={() => {
General.clearClipboard();
}}
onFocus={() => clearClipboard()}
onBlur={() => clearClipboard()}
onPressIn={() => clearClipboard()}
onSelectionChange={onSelectionChange}
selection={inputTextSelection}
keyboardType={props.secureTextEntry ? 'default' : 'visible-password'} // hides additional options like clipboard when password is shown (on some devices)
autoCapitalize={'none'}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class SelectableItemGroup extends React.Component {
this.props.onPress(radioLabelValue.value, radioLabelValue.label);
}
return (
<Text style={Styles.formLabel}>{radioLabelValue.label}</Text>
<Text style={Styles.formLabel}>{this.props.I18n.t(radioLabelValue.label)}</Text>
)
}

Expand Down

0 comments on commit 26c646d

Please sign in to comment.