Skip to content

Commit

Permalink
fix: adding app version failsafe to the submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Sep 21, 2021
1 parent b7f280f commit 990e269
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 3 additions & 1 deletion domains/DataCollection/Assets/NewAssets/AssetCore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import _ from 'lodash';
import React, { useEffect, useState } from 'react';
import {
ActivityIndicator,
Platform,
ScrollView, View
} from 'react-native';
import {
Expand Down Expand Up @@ -43,7 +44,8 @@ const AssetCore = ({
setSubmitting(true);
formObject.surveyingUser = await surveyingUserFailsafe(user, surveyingUser, isEmpty);
formObject.surveyingOrganization = surveyingOrganization;
formObject.appVersion = await getData('appVersion');
formObject.appVersion = await getData('appVersion') || '';
formObject.phoneOS = Platform.OS || '';
formObject.latitude = values.location?.latitude || 0;
formObject.longitude = values.location?.longitude || 0;
formObject.altitude = values.location?.altitude || 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Formik } from 'formik';
import React, { useState } from 'react';
import { ActivityIndicator, TouchableWithoutFeedback, View } from 'react-native';
import {
ActivityIndicator, Platform, TouchableWithoutFeedback, View
} from 'react-native';
import { ScrollView } from 'react-native-gesture-handler';

import AssetSearchbar from '../../../../../components/AssetSearchBar/index';
Expand Down Expand Up @@ -41,7 +43,7 @@ const AssetSupplementary = ({
const user = await getData('currentUser');

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

const formObjectUpdated = addSelectTextInputs(values, formObject);

Expand All @@ -67,7 +69,8 @@ const AssetSupplementary = ({
fields: fieldsArray,
surveyingOrganization,
surveyingUser: surveyingUserFailSafe,
appVersion
appVersion,
phoneOS: Platform.OS || ''
};

const submitAction = () => {
Expand Down
6 changes: 4 additions & 2 deletions domains/DataCollection/Forms/IdentificationForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import React, { useEffect, useState } from 'react';
import {
ActivityIndicator,
Keyboard,
TouchableWithoutFeedback, View,
Platform,
TouchableWithoutFeedback, View
} from 'react-native';

import PaperButton from '../../../../components/Button';
Expand Down Expand Up @@ -49,7 +50,8 @@ const IdentificationForm = ({

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

formObject.latitude = values.location?.latitude || 0;
formObject.longitude = values.location?.longitude || 0;
Expand Down
4 changes: 3 additions & 1 deletion domains/DataCollection/Forms/SupplementaryForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Formik } from 'formik';
import React, { useEffect, useState } from 'react';
import {
ActivityIndicator,
Platform,
View
} from 'react-native';
import { Button, Text } from 'react-native-paper';
Expand Down Expand Up @@ -65,7 +66,8 @@ const SupplementaryForm = ({

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

let formObjectUpdated = addSelectTextInputs(values, formObject);
if (selectedForm === 'vitals') {
Expand Down
4 changes: 2 additions & 2 deletions modules/cached-resources/populate-cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Constants from 'expo-constants';
import * as Updates from 'expo-updates';

import { retrievAddUserPushToken, retrieveCurrentUserAsyncFunction } from '../../services/parse/auth';
import { getData, storeData } from '../async-storage';
Expand Down Expand Up @@ -78,7 +78,7 @@ export default function populateCache(user, expoToken) {
})
.then(async () => {
// store current app version
const appVersion = Constants.manifest.version;
const appVersion = Updates.manifest.version;
await getData('appVersion').then(async (currentAppVersion) => {
if (appVersion !== currentAppVersion && appVersion !== null && appVersion !== undefined) {
await storeData(appVersion, 'appVersion');
Expand Down

0 comments on commit 990e269

Please sign in to comment.