From 990e26908ae3b17e89ac31897609539f6850922d Mon Sep 17 00:00:00 2001 From: Hope Tambala Date: Tue, 21 Sep 2021 17:49:41 -0400 Subject: [PATCH] fix: adding app version failsafe to the submissions --- .../DataCollection/Assets/NewAssets/AssetCore/index.js | 4 +++- .../Assets/NewAssets/AssetSupplementary/index.js | 9 ++++++--- domains/DataCollection/Forms/IdentificationForm/index.js | 6 ++++-- domains/DataCollection/Forms/SupplementaryForm/index.js | 4 +++- modules/cached-resources/populate-cache.js | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/domains/DataCollection/Assets/NewAssets/AssetCore/index.js b/domains/DataCollection/Assets/NewAssets/AssetCore/index.js index 25ae13b81..cae2ea701 100644 --- a/domains/DataCollection/Assets/NewAssets/AssetCore/index.js +++ b/domains/DataCollection/Assets/NewAssets/AssetCore/index.js @@ -3,6 +3,7 @@ import _ from 'lodash'; import React, { useEffect, useState } from 'react'; import { ActivityIndicator, + Platform, ScrollView, View } from 'react-native'; import { @@ -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; diff --git a/domains/DataCollection/Assets/NewAssets/AssetSupplementary/index.js b/domains/DataCollection/Assets/NewAssets/AssetSupplementary/index.js index ca40aecf6..bc278b4bd 100644 --- a/domains/DataCollection/Assets/NewAssets/AssetSupplementary/index.js +++ b/domains/DataCollection/Assets/NewAssets/AssetSupplementary/index.js @@ -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'; @@ -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); @@ -67,7 +69,8 @@ const AssetSupplementary = ({ fields: fieldsArray, surveyingOrganization, surveyingUser: surveyingUserFailSafe, - appVersion + appVersion, + phoneOS: Platform.OS || '' }; const submitAction = () => { diff --git a/domains/DataCollection/Forms/IdentificationForm/index.js b/domains/DataCollection/Forms/IdentificationForm/index.js index a0a273e14..2b8ddcf19 100644 --- a/domains/DataCollection/Forms/IdentificationForm/index.js +++ b/domains/DataCollection/Forms/IdentificationForm/index.js @@ -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'; @@ -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; diff --git a/domains/DataCollection/Forms/SupplementaryForm/index.js b/domains/DataCollection/Forms/SupplementaryForm/index.js index e38366a2d..ba28e4d38 100644 --- a/domains/DataCollection/Forms/SupplementaryForm/index.js +++ b/domains/DataCollection/Forms/SupplementaryForm/index.js @@ -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'; @@ -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') { diff --git a/modules/cached-resources/populate-cache.js b/modules/cached-resources/populate-cache.js index 36dde252a..14f6f6fbf 100644 --- a/modules/cached-resources/populate-cache.js +++ b/modules/cached-resources/populate-cache.js @@ -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'; @@ -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');