Resolve delete on upload for LMS on iOS.

This commit is contained in:
Patrick Fic
2025-11-26 14:30:05 -08:00
parent c79556c04a
commit d0ad90a012
2 changed files with 13 additions and 6 deletions

View File

@@ -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 (
<Switch
onValueChange={() => {
setState(!state);
toggleDeleteAfterUpload();
}}
value={Platform.OS === "android" ? false : deleteAfterUpload}
value={Platform.OS === "android" ? false : state}
disabled={Platform.OS === "android"}
/>
);

View File

@@ -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));
}
}