diff --git a/components/settings/upload-delete-switch.jsx b/components/settings/upload-delete-switch.jsx index 7b9ad4f..b43a624 100644 --- a/components/settings/upload-delete-switch.jsx +++ b/components/settings/upload-delete-switch.jsx @@ -1,6 +1,6 @@ import React from "react"; -import { Platform } from "react-native"; -import { Switch } from "react-native-paper"; +import { Platform, Switch } from "react-native"; +//import { Switch } from "react-native-paper"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import { toggleDeleteAfterUpload } from "../../redux/app/app.actions"; @@ -18,12 +18,16 @@ export function UploadDeleteSwitch({ deleteAfterUpload, toggleDeleteAfterUpload, }) { + //Required workaround to prevent double-tap issue. + const [state, setState] = React.useState(deleteAfterUpload); + return ( { + setState(!state); toggleDeleteAfterUpload(); }} - value={Platform.OS === "android" ? false : deleteAfterUpload} + value={Platform.OS === "android" ? false : state} disabled={Platform.OS === "android"} /> ); diff --git a/redux/photos/photos.sagas.js b/redux/photos/photos.sagas.js index 8c4e005..f8f5f11 100644 --- a/redux/photos/photos.sagas.js +++ b/redux/photos/photos.sagas.js @@ -222,7 +222,6 @@ function* uploadToLocalMediaServer(photos, bodyshop, jobid) { try { const startTime = new Date(); const handleUploadProgress = (e) => { - console.log("progress", e) store.dispatch(mediaUploadProgressBulk({ progress: e.loaded / e.total, loaded: e.loaded, total: e.total, startTime })); }; @@ -410,7 +409,11 @@ function* mediaUploadCompletedAction({ payload: photos }) { try { const progress = yield select((state) => state.photos.progress); // Handle the completion of media uploads - const filesToDelete = Object.keys(progress).filter((key) => progress[key].status === 'completed').map((key) => progress[key]); + + //If using LMS, the progress object has only 1 key and that can't be used here. + //We'd only be here if the upload was entirely succesful, so we can assume to delete all photos. + const uselocalmediaserver = yield select((state) => state.user.bodyshop.uselocalmediaserver); + const filesToDelete = uselocalmediaserver ? photos : Object.keys(progress).filter((key) => progress[key].status === 'completed').map((key) => progress[key]); if (Platform.OS === "android") { Alert.alert( @@ -483,7 +486,7 @@ function* mediaUploadCompletedAction({ payload: photos }) { yield put(deleteMediaSuccess(photos)); } catch (error) { - console.log("Saga Error: upload start", error, error.stack); + console.log("Saga Error: upload completed", error, error.stack); yield put(mediaUploadFailure(error.message)); } }