1.3.6-7 Production Build - Resolve errors on local upload and deleting.

This commit is contained in:
Patrick Fic
2022-05-20 09:46:34 -07:00
parent adb03f4f31
commit c5a31cf376
3 changed files with 27 additions and 28 deletions

View File

@@ -59,7 +59,7 @@ export function UploadProgress({
}
}, [uploads]);
function handleOnSuccess({ duration }) {
async function handleOnSuccess({ duration, data }) {
//If it's not in production, show a toast with the time.
Toast.show({
type: "success",
@@ -67,8 +67,16 @@ export function UploadProgress({
//
// text2: duration,
});
if (deleteAfterUpload) {
try {
await MediaLibrary.deleteAssetsAsync(data);
} catch (error) {
console.log("Unable to delete picture.", error);
}
}
logImEXEvent("imexmobile_successful_upload");
forceRerender();
setProgress({ ...progress, speed: 0, percent: 1, uploadInProgress: false });
}
@@ -86,9 +94,14 @@ export function UploadProgress({
Toast.show({
type: "error",
text1: "Unable to upload documents.",
text2: (error && error.message) || JSON.stringify(error),
text2: error,
autoHide: false,
});
setProgress({
speed: 0,
percent: 1,
uploadInProgress: false,
});
}
const beginUploads = async (data) => {
@@ -106,28 +119,12 @@ export function UploadProgress({
onError: ({ assetid, error }) => handleOnError({ assetid, error }),
onProgress: ({ percent, loaded }) =>
handleOnProgress({ percent, loaded }),
onSuccess: ({ duration }) => handleOnSuccess({ duration }),
onSuccess: ({ duration }) => handleOnSuccess({ duration, data }),
context: {
jobid:
selectedCameraJobId !== "temp" ? selectedCameraJobId : "temporary",
},
});
if (deleteAfterUpload) {
try {
await MediaLibrary.deleteAssetsAsync(data);
} catch (error) {
console.log("Unable to delete picture.", error);
}
}
setProgress({
loading: false,
speed: 0,
uploadInProgress: false,
});
forceRerender();
};
return (