diff --git a/android/app/build.gradle b/android/app/build.gradle index c4fc246d..7ad06449 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -140,7 +140,7 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 38 - versionName "1.0.14" + versionName "1.0.15" buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() diff --git a/src/form/Attributes/File/hooks/useImage.js b/src/form/Attributes/File/hooks/useImage.js index cf9a3f14..d4d4179b 100644 --- a/src/form/Attributes/File/hooks/useImage.js +++ b/src/form/Attributes/File/hooks/useImage.js @@ -60,8 +60,8 @@ const useGetImage = ({cropping = false} = {}) => { Platform.OS === 'ios' ? Math.min(0.8, compressQuality) // this is because in IOS 0.8 is more than enough : compressQuality, - compressImageMaxHeight: compressMaxHeight, - compressImageMaxWidth: compressMaxWidth, + compressImageMaxHeight: Math.floor(compressMaxHeight), + compressImageMaxWidth: Math.floor(compressMaxWidth), }), }); diff --git a/src/infra/api/index.js b/src/infra/api/index.js index cdd3ef69..15c0d08c 100644 --- a/src/infra/api/index.js +++ b/src/infra/api/index.js @@ -66,9 +66,17 @@ export default ({serverUrl = SERVER_URL}) => { contentType, }); - const postFile = async (uri, file, onProgress) => { + const postFile = async ( + uri, + file, + onProgress, + conflictResolutionStrategy, + ) => { let formData = new FormData(); formData.append('file', file); + if (conflictResolutionStrategy) { + formData.append('conflictResolutionStrategy', conflictResolutionStrategy); + } return axios.post(uri, formData, { headers: {'Content-Type': 'multipart/form-data'}, onUploadProgress: onProgress, diff --git a/src/infra/fs/index.js b/src/infra/fs/index.js index 48dc9d6b..b10be82e 100644 --- a/src/infra/fs/index.js +++ b/src/infra/fs/index.js @@ -133,7 +133,13 @@ export const deleteDir = async path => { return RNFetchBlob.fs.unlink(_path); }; -export const uploadFiles = async ({uploadUrl, files, onStart, onProgress}) => { +export const uploadFiles = async ({ + uploadUrl, + files, + onStart, + onProgress, + conflictResolutionStrategy, +}) => { const _files = files.map(file => Object.assign({}, file, { type: file.filetype, @@ -147,12 +153,17 @@ export const uploadFiles = async ({uploadUrl, files, onStart, onProgress}) => { type: _files[0].type, }; - return API({}).postFile(uploadUrl, file, progress => { - onProgress({ - totalBytesSent: progress.loaded, - totalBytesExpectedToSend: progress.total, - }); - }); + return API({}).postFile( + uploadUrl, + file, + progress => { + onProgress({ + totalBytesSent: progress.loaded, + totalBytesExpectedToSend: progress.total, + }); + }, + conflictResolutionStrategy, + ); }; const blobToBase64 = data => { diff --git a/src/screens/Form/components/EntityPage/component.js b/src/screens/Form/components/EntityPage/component.js index 25c0827e..8745376e 100644 --- a/src/screens/Form/components/EntityPage/component.js +++ b/src/screens/Form/components/EntityPage/component.js @@ -16,7 +16,10 @@ const EntityPage = () => { () => NodeDefs.getLayoutRenderType(cycle)(nodeDef) === 'table', [nodeDef, cycle], ); - const isMultiple = useMemo(() => NodeDefs.isMultiple(nodeDef), [nodeDef]); + const isMultiple = useMemo( + () => (nodeDef?.props ? NodeDefs.isMultiple(nodeDef) : false), + [nodeDef], + ); if (nodeDef?.uuid && NodeDefs.isEntity(nodeDef)) { return isTable || isMultiple ? : ; diff --git a/src/screens/Settings/Screens/ImagesQualityAndSize/ImageQualitySettings/component.js b/src/screens/Settings/Screens/ImagesQualityAndSize/ImageQualitySettings/component.js index 240e986a..ac4575bc 100644 --- a/src/screens/Settings/Screens/ImagesQualityAndSize/ImageQualitySettings/component.js +++ b/src/screens/Settings/Screens/ImagesQualityAndSize/ImageQualitySettings/component.js @@ -36,7 +36,7 @@ const SettingsImagesQualityAndSize = () => { value => { dispatch( appActions.setImagesCompressMaxHeight({ - compressMaxHeight: value, + compressMaxHeight: Math.floor(value), }), ); }, @@ -47,7 +47,7 @@ const SettingsImagesQualityAndSize = () => { value => { dispatch( appActions.setImagesCompressMaxWidth({ - compressMaxWidth: value, + compressMaxWidth: Math.floor(value), }), ); }, diff --git a/src/state/survey/sagas/uploadData/index.js b/src/state/survey/sagas/uploadData/index.js index 3730bbb9..bd8519b7 100644 --- a/src/state/survey/sagas/uploadData/index.js +++ b/src/state/survey/sagas/uploadData/index.js @@ -45,6 +45,7 @@ function* checkIfShouldUpdate({recordUuid}) { } function* handlePrepareRecordsData() { + let numberOfRecordsToUpload = 0; try { yield call(fs.mkdir, {dirPath: RECORDS_BASE_PATH}); const surveyUuid = yield select(surveySelectors.getSelectedSurveyUuid); @@ -58,6 +59,7 @@ function* handlePrepareRecordsData() { const shouldUpdate = yield call(checkIfShouldUpdate, {recordUuid}); if (shouldUpdate) { recordsJson.push({uuid: recordUuid, cycle}); + numberOfRecordsToUpload = numberOfRecordsToUpload + 1; yield call(fs.copyFile, { sourcePath: recordFile.path, destinationPath: `${RECORDS_BASE_PATH}/${recordUuid}.json`, @@ -74,6 +76,7 @@ function* handlePrepareRecordsData() { } finally { console.log('Finally:recordsData'); } + return numberOfRecordsToUpload; } function* handlePrepareFilesData() { @@ -139,8 +142,9 @@ function* handlePrepareFilesData() { } function* handlePrepareZipData() { + let numberOfRecordsToUpload = 0; try { - yield call(handlePrepareRecordsData); + numberOfRecordsToUpload = yield call(handlePrepareRecordsData); yield call(handlePrepareFilesData); yield call(zip, { @@ -154,6 +158,7 @@ function* handlePrepareZipData() { } finally { console.log('Finally'); } + return numberOfRecordsToUpload; } function* cleanTmpFolder() { @@ -223,9 +228,12 @@ function* handleUploadData() { yield call(cleanTmpFolder); yield call(fs.mkdir, {dirPath: TMP_SURVEYS_BASE_PATH}); - yield call(handlePrepareZipData); + const numberOfRecordsToUpload = yield call(handlePrepareZipData); // UPLOAD DATA and track progress + if (numberOfRecordsToUpload === 0) { + return; + } yield call(WS({serverUrl}).create); yield call(WS({serverUrl}).on, { eventName: WebSocketEvents.jobUpdate, diff --git a/src/state/surveys/api/api.js b/src/state/surveys/api/api.js index a7aba200..8074bce2 100644 --- a/src/state/surveys/api/api.js +++ b/src/state/surveys/api/api.js @@ -45,6 +45,7 @@ const uploadSurveyZip = async ({ files, onStart, onProgress, + conflictResolutionStrategy: 'overwriteIfUpdated', }); };