diff --git a/app.json b/app.json index 1881d7f..3a5c2df 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "slug": "imexmobile", "version": "1.6.0", "extra": { - "expover": "4", + "expover": "5", "eas": { "projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b" } @@ -24,7 +24,7 @@ }, "android": { "package": "com.imex.imexmobile", - "versionCode": 1100029, + "versionCode": 1100030, "googleServicesFile": "./google-services.json", "permissions": [ "android.permission.READ_EXTERNAL_STORAGE", diff --git a/components/local-upload-progress/local-upload-progress.component.jsx b/components/local-upload-progress/local-upload-progress.component.jsx index c7800fa..ab237f0 100644 --- a/components/local-upload-progress/local-upload-progress.component.jsx +++ b/components/local-upload-progress/local-upload-progress.component.jsx @@ -1,5 +1,5 @@ -import * as MediaLibrary from "expo-media-library"; -import React, { useEffect, useState } from "react"; +import * as MediaLibrary from 'expo-media-library'; +import React, { useEffect, useState } from 'react'; import { ActivityIndicator, @@ -8,20 +8,20 @@ import { StyleSheet, Text, View, -} from "react-native"; -import { ProgressBar } from "react-native-paper"; -import Toast from "react-native-toast-message"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { logImEXEvent } from "../../firebase/firebase.analytics"; +} from 'react-native'; +import { ProgressBar } from 'react-native-paper'; +import Toast from 'react-native-toast-message'; +import { connect } from 'react-redux'; +import { createStructuredSelector } from 'reselect'; +import { logImEXEvent } from '../../firebase/firebase.analytics'; import { selectCurrentCameraJobId, selectDeleteAfterUpload, -} from "../../redux/app/app.selectors"; +} from '../../redux/app/app.selectors'; import * as Sentry from '@sentry/react-native'; -import { formatBytes } from "../../util/document-upload.utility"; -import { handleLocalUpload } from "../../util/local-document-upload.utility"; +import { formatBytes } from '../../util/document-upload.utility'; +import { handleLocalUpload } from '../../util/local-document-upload.utility'; const mapStateToProps = createStructuredSelector({ selectedCameraJobId: selectCurrentCameraJobId, @@ -54,7 +54,7 @@ export function UploadProgress({ async function handleOnSuccess({ duration, data }) { //If it's not in production, show a toast with the time. Toast.show({ - type: "success", + type: 'success', text1: ` Upload completed in ${duration}.`, // // text2: duration, @@ -63,45 +63,27 @@ export function UploadProgress({ try { await MediaLibrary.deleteAssetsAsync(data); - - try { - const album = await MediaLibrary.createAlbumAsync( - 'ImEX Mobile Deleted', - data.pop(), + const album = await MediaLibrary.createAlbumAsync( + 'ImEX Mobile Deleted', + data.pop(), + false + ); + //Move the rest. + if (data.length > 0) { + const moveResult = await MediaLibrary.addAssetsToAlbumAsync( + data, + album, false ); - //Move the rest. - if (data.length > 0) { - const moveResult = await MediaLibrary.addAssetsToAlbumAsync( - data, - album, - false - ); - } - const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); - Toast.show({ - type: 'success', - text1: 'Pictures deleted succesfully.', - text2: JSON.stringify(deleteResult), - autoHide: false, - }); - } catch (error) { - console.log("🚀 ~ onDone ~ error:", error) - Toast.show({ - type: 'error', - text1: 'deleteAlbumsAsync', - text2: JSON.stringify(error), - autoHide: false, - }); } - + const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); } catch (error) { - console.log("Unable to delete picture.", error); + console.log('Unable to delete picture.', error); Sentry.Native.captureException(error); } } - logImEXEvent("imexmobile_successful_upload"); + logImEXEvent('imexmobile_successful_upload'); forceRerender(); setProgress({ ...progress, speed: 0, percent: 1, uploadInProgress: false }); } @@ -116,10 +98,10 @@ export function UploadProgress({ } function handleOnError({ assetid, error }) { - logImEXEvent("imexmobile_upload_documents_error"); + logImEXEvent('imexmobile_upload_documents_error'); Toast.show({ - type: "error", - text1: "Unable to upload documents.", + type: 'error', + text1: 'Unable to upload documents.', text2: error, autoHide: false, }); @@ -148,7 +130,7 @@ export function UploadProgress({ onSuccess: ({ duration }) => handleOnSuccess({ duration, data }), context: { jobid: - selectedCameraJobId !== "temp" ? selectedCameraJobId : "temporary", + selectedCameraJobId !== 'temp' ? selectedCameraJobId : 'temporary', }, }); }; @@ -156,41 +138,41 @@ export function UploadProgress({ return ( { - Alert.alert("Cancel?", "Do you want to abort the upload?", [ + Alert.alert('Cancel?', 'Do you want to abort the upload?', [ { - text: "Yes", + text: 'Yes', onPress: () => { setUploads(null); setProgress(null); }, }, - { text: "No" }, + { text: 'No' }, ]); }} > - + - {`${formatBytes( + {`${formatBytes( progress.speed )}/sec`} {`Avg. ${formatBytes( progress.loaded / ((new Date() - progress.start) / 1000) )}/sec`} {`Total Uploaded ${formatBytes(progress.loaded)}`} - {`Duration ${( + {`Duration ${( (new Date() - progress.start) / 1000 ).toFixed(1)} sec`} @@ -201,19 +183,19 @@ export function UploadProgress({ } const styles = StyleSheet.create({ modalContainer: { - display: "flex", + display: 'flex', flex: 1, - justifyContent: "center", + justifyContent: 'center', }, modal: { // flex: 1, - display: "flex", + display: 'flex', marginLeft: 20, marginRight: 20, - backgroundColor: "white", + backgroundColor: 'white', borderRadius: 20, padding: 18, - shadowColor: "#000", + shadowColor: '#000', shadowOffset: { width: 0, height: 2, diff --git a/components/upload-progress/upload-progress.component.jsx b/components/upload-progress/upload-progress.component.jsx index 22498fc..3b81f93 100644 --- a/components/upload-progress/upload-progress.component.jsx +++ b/components/upload-progress/upload-progress.component.jsx @@ -208,100 +208,22 @@ export function UploadProgress({ //Create a new asset with the first file to delete. // console.log('Trying new delete.'); await MediaLibrary.getPermissionsAsync(false); - // try { - // const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync( - // filesToDelete, - // filesToDelete[0].albumId - // ); - // Toast.show({ - // type: 'info', - // text1: 'removeAssetsFromAlbumAsync', - // text2: JSON.stringify(albumremove), - // autoHide: false, - // }); - // } catch (error) { - // console.log("🚀 ~ onDone ~ error:", error) - // Toast.show({ - // type: 'error', - // text1: 'removeAssetsFromAlbumAsync', - // text2: JSON.stringify(error), - // autoHide: false, - // }); - // } - // try { - // const delres = await MediaLibrary.deleteAssetsAsync( - // filesToDelete.map((f) => f.id) - // ); - - // Toast.show({ - // type: 'info', - // text1: 'deleteAssetsAsync', - // text2: JSON.stringify(delres), - // autoHide: false, - // }); - // } catch (error) { - // console.log("🚀 ~ onDone ~ error:", error) - // Toast.show({ - // type: 'error', - // text1: 'deleteAssetsAsync', - // text2: JSON.stringify(error), - // autoHide: false, - // }); - // } - - // try { - // const res = Promise.all( - // filesToDelete.map((f) => - // FileSystem.deleteAsync(f.uri, { idempotent: true }) - // ) - // ); - // Toast.show({ - // type: 'info', - // text1: 'FileSystemDelete', - // text2: JSON.stringify(res), - // autoHide: false, - // }); - // } catch (error) { - // console.log("🚀 ~ onDone ~ error:", error) - // Toast.show({ - // type: 'error', - // text1: 'FileSystemDelete', - // text2: JSON.stringify(error), - // autoHide: false, - // }); - // } - - try { - const album = await MediaLibrary.createAlbumAsync( - 'ImEX Mobile Deleted', - filesToDelete.pop(), + const album = await MediaLibrary.createAlbumAsync( + 'ImEX Mobile Deleted', + filesToDelete.pop(), + false + ); + //Move the rest. + if (filesToDelete.length > 0) { + const moveResult = await MediaLibrary.addAssetsToAlbumAsync( + filesToDelete, + album, false ); - //Move the rest. - if (filesToDelete.length > 0) { - const moveResult = await MediaLibrary.addAssetsToAlbumAsync( - filesToDelete, - album, - false - ); - } - const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); - Toast.show({ - type: 'success', - text1: 'Pictures deleted succesfully.', - text2: JSON.stringify(deleteResult), - autoHide: false, - }); - } catch (error) { - console.log("🚀 ~ onDone ~ error:", error) - Toast.show({ - type: 'error', - text1: 'deleteAlbumsAsync', - text2: JSON.stringify(error), - autoHide: false, - }); } + const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); + //Delete the album. //This defaults to delete all assets in the album.