Skip to content

Commit

Permalink
fix: app version in data
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Oct 10, 2022
1 parent 23de42e commit 46afbc7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import PaperInputPicker from '../../../../../components/FormikFields/PaperInputP
import PopupError from '../../../../../components/PopupError';
import { getData } from '../../../../../modules/async-storage';
import { postSupplementaryAssetForm } from '../../../../../modules/cached-resources';
import { storeAppVersion } from '../../../../../modules/cached-resources/populate-cache';
import I18n from '../../../../../modules/i18n';
import { theme } from '../../../../../modules/theme';
import { isEmpty } from '../../../../../modules/utils';
Expand Down Expand Up @@ -45,7 +46,7 @@ const AssetSupplementary = ({
const user = await getData('currentUser');

const surveyingUserFailSafe = await surveyingUserFailsafe(user, surveyingUser, isEmpty);
const appVersion = await getData('appVersion') || '';
const appVersion = await storeAppVersion() || '';

let formObjectUpdated = addSelectTextInputs(values, formObject);
formObjectUpdated = cleanLoopSubmissions(values, formObjectUpdated);
Expand Down
4 changes: 3 additions & 1 deletion domains/DataCollection/Forms/IdentificationForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import yupValidationPicker from '../../../../components/FormikFields/YupValidati
import PopupError from '../../../../components/PopupError';
import { getData } from '../../../../modules/async-storage';
import { postIdentificationForm } from '../../../../modules/cached-resources';
import { storeAppVersion } from '../../../../modules/cached-resources/populate-cache';
import I18n from '../../../../modules/i18n';
import { layout, theme } from '../../../../modules/theme';
import { isEmpty } from '../../../../modules/utils';
Expand Down Expand Up @@ -52,7 +53,8 @@ const IdentificationForm = ({

formObject.surveyingOrganization = surveyingOrganization || user.organization;
formObject.surveyingUser = await surveyingUserFailsafe(user, surveyingUser, isEmpty);
formObject.appVersion = await getData('appVersion') || '';

formObject.appVersion = await storeAppVersion() || '';
formObject.phoneOS = Platform.OS || '';

formObject.latitude = values.location?.latitude || 0;
Expand Down
10 changes: 3 additions & 7 deletions modules/cached-resources/populate-cache.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import Constants from 'expo-constants';

import { getData, storeData } from '../async-storage';
import { storeData } from '../async-storage';
import {
assetDataQuery, assetFormsQuery, cacheAutofillData, customFormsQuery
} from './read';

const storeAppVersion = async () => {
export const storeAppVersion = async () => {
const appVersion = Constants.manifest.version;
await getData('appVersion').then(async (currentAppVersion) => {
if (appVersion !== currentAppVersion && appVersion) {
await storeData(appVersion, 'appVersion');
}
});
return storeData(appVersion, 'appVersion');
};

const populateCache = async (user) => {
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
"react-native-screens": "~3.15.0",
"react-native-svg": "12.3.0",
"react-native-uuid": "^2.0.1",
"yup": "0.29.3"
"yup": "0.29.3",
"expo-application": "~4.2.2"
},
"devDependencies": {
"@babel/core": "^7.18.6",
Expand Down
25 changes: 19 additions & 6 deletions services/parse/client/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
// import AsyncStorage from '@react-native-async-storage/async-storage';

// const client = (isTest) => {
// if (isTest) {
// const { Parse } = import ('parse/node');
// return Parse
// };
// const { Parse } = import('parse/react-native');

// Parse.setAsyncStorage(AsyncStorage);
// return Parse;
// };

// export default client;

import AsyncStorage from '@react-native-async-storage/async-storage';
import { Parse as ParseNode } from 'parse/node';
import { Parse as ParseRN } from 'parse/react-native';
import { Parse } from 'parse/react-native';

const client = (isTest) => {
if (isTest) return ParseNode;
ParseRN.setAsyncStorage(AsyncStorage);
return ParseRN;
const client = () => {
Parse.setAsyncStorage(AsyncStorage);
return Parse;
};

export default client;

0 comments on commit 46afbc7

Please sign in to comment.