Demo adjustments, resolve upload issues, remove messaging.

This commit is contained in:
Patrick Fic
2021-01-12 18:28:58 -08:00
parent 06dda3639f
commit 7d1a265dee
18 changed files with 656 additions and 78 deletions

View File

@@ -1,6 +1,7 @@
import * as FileSystem from "expo-file-system";
import { all, call, select, takeLatest } from "redux-saga/effects";
import { all, call, delay, put, select, takeLatest } from "redux-saga/effects";
import { handleUpload } from "../../util/document-upload.utility";
import { uploadPhotosFailure, uploadPhotosSuccess } from "./photos.actions";
import PhotosActionTypes from "./photos.types";
export function* onRemovePhotos() {
@@ -52,32 +53,38 @@ export function* onUploadAllPhotos() {
export function* uploadAllPhotosAction() {
try {
yield delay(500);
const photos = yield select((state) => state.photos.photos);
const bodyshop = yield select((state) => state.user.bodyshop);
const user = yield select((state) => state.user);
const actions = [];
photos.forEach(async (p) =>
photos.forEach(function (p) {
actions.push(
await handleUpload(
{
file: await (await fetch(p.uri)).blob(),
onError: handleOnError,
onProgress: handleOnProgress,
onSuccess: handleOnSuccess,
},
{
bodyshop: bodyshop,
jobId: p.jobId,
uploaded_by: user.currentUser.email,
photo: p,
}
call(
handleUpload,
...[
{
uri: p.uri,
onError: handleOnError,
onProgress: handleOnProgress,
onSuccess: handleOnSuccess,
},
{
bodyshop: bodyshop,
jobId: p.jobId,
uploaded_by: user.currentUser.email,
photo: p,
},
]
)
)
);
yield Promise.all(actions);
console.log("function*uploadAllPhotosAction -> actions", actions);
);
});
yield all(actions);
yield put(removeAllPhotos());
yield put(uploadPhotosSuccess());
} catch (error) {
console.log("Saga Error: onRemoveAllPhotos", error);
console.log("Saga Error: uploadAllPhotosAction", error);
yield put(uploadPhotosFailure(error));
}
}