Attempted upload progress fixes.
This commit is contained in:
@@ -65,9 +65,9 @@ export function UploadProgress({
|
||||
|
||||
//if (!uploads) return null;
|
||||
|
||||
function handleOnSuccess(id) {
|
||||
function handleOnSuccess(id, asset) {
|
||||
logImEXEvent("imexmobile_successful_upload");
|
||||
filesToDelete.push(id);
|
||||
filesToDelete.push(asset);
|
||||
setProgress((progress) => ({
|
||||
...progress,
|
||||
action: t("mediabrowser.labels.converting"),
|
||||
@@ -127,6 +127,8 @@ export function UploadProgress({
|
||||
const totalOfUploads = await data.reduce(async (acc, val) => {
|
||||
//Get the size of the file based on URI.
|
||||
const info = await FileSystem.getInfoAsync(val.uri, { size: true });
|
||||
|
||||
val.albumId && MediaLibrary.migrateAlbumIfNeededAsync(val.albumId);
|
||||
return (await acc) + info.size;
|
||||
}, 0);
|
||||
|
||||
@@ -150,7 +152,7 @@ export function UploadProgress({
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("DATA", data);
|
||||
//Sequentially await the proms.
|
||||
|
||||
for (var i = 0; i < data.length + 4; i = i + 4) {
|
||||
@@ -173,7 +175,22 @@ export function UploadProgress({
|
||||
|
||||
if (deleteAfterUpload) {
|
||||
try {
|
||||
await MediaLibrary.deleteAssetsAsync(filesToDelete);
|
||||
const res = await Promise.all(
|
||||
filesToDelete.map(async (f) =>
|
||||
MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId)
|
||||
)
|
||||
);
|
||||
|
||||
const deleteResult = await MediaLibrary.deleteAssetsAsync(
|
||||
filesToDelete
|
||||
);
|
||||
|
||||
console.log("res", res);
|
||||
console.log(
|
||||
"🚀 ~ file: upload-progress.component.jsx ~ line 177 ~ deleteResult",
|
||||
filesToDelete,
|
||||
deleteResult
|
||||
);
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
}
|
||||
@@ -202,7 +219,7 @@ export function UploadProgress({
|
||||
onError: handleOnError,
|
||||
onProgress: ({ percent, loaded }) =>
|
||||
handleOnProgress(p.id, percent, loaded),
|
||||
onSuccess: () => handleOnSuccess(p.id),
|
||||
onSuccess: () => handleOnSuccess(p.id, p),
|
||||
},
|
||||
{
|
||||
bodyshop: bodyshop,
|
||||
|
||||
Reference in New Issue
Block a user