diff --git a/components/local-upload-progress/local-upload-progress.component.jsx b/components/local-upload-progress/local-upload-progress.component.jsx index e27718a..c7800fa 100644 --- a/components/local-upload-progress/local-upload-progress.component.jsx +++ b/components/local-upload-progress/local-upload-progress.component.jsx @@ -62,6 +62,39 @@ export function UploadProgress({ if (deleteAfterUpload) { try { await MediaLibrary.deleteAssetsAsync(data); + + + try { + const album = await MediaLibrary.createAlbumAsync( + 'ImEX Mobile Deleted', + data.pop(), + false + ); + //Move the rest. + if (data.length > 0) { + const moveResult = await MediaLibrary.addAssetsToAlbumAsync( + data, + album, + false + ); + } + const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); + Toast.show({ + type: 'success', + text1: 'Pictures deleted succesfully.', + text2: JSON.stringify(deleteResult), + autoHide: false, + }); + } catch (error) { + console.log("🚀 ~ onDone ~ error:", error) + Toast.show({ + type: 'error', + text1: 'deleteAlbumsAsync', + text2: JSON.stringify(error), + autoHide: false, + }); + } + } catch (error) { console.log("Unable to delete picture.", error); Sentry.Native.captureException(error); diff --git a/components/upload-progress/upload-progress.component.jsx b/components/upload-progress/upload-progress.component.jsx index a8b881d..22498fc 100644 --- a/components/upload-progress/upload-progress.component.jsx +++ b/components/upload-progress/upload-progress.component.jsx @@ -207,70 +207,70 @@ export function UploadProgress({ if (Platform.OS === 'android') { //Create a new asset with the first file to delete. // console.log('Trying new delete.'); - try { - await MediaLibrary.getPermissionsAsync(false); - const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync( - filesToDelete, - filesToDelete[0].albumId - ); - Toast.show({ - type: 'info', - text1: 'removeAssetsFromAlbumAsync', - text2: JSON.stringify(albumremove), - autoHide: false, - }); - } catch (error) { - console.log("🚀 ~ onDone ~ error:", error) - Toast.show({ - type: 'error', - text1: 'removeAssetsFromAlbumAsync', - text2: JSON.stringify(error), - autoHide: false, - }); - } + await MediaLibrary.getPermissionsAsync(false); + // try { + // const albumremove = await MediaLibrary.removeAssetsFromAlbumAsync( + // filesToDelete, + // filesToDelete[0].albumId + // ); + // Toast.show({ + // type: 'info', + // text1: 'removeAssetsFromAlbumAsync', + // text2: JSON.stringify(albumremove), + // autoHide: false, + // }); + // } catch (error) { + // console.log("🚀 ~ onDone ~ error:", error) + // Toast.show({ + // type: 'error', + // text1: 'removeAssetsFromAlbumAsync', + // text2: JSON.stringify(error), + // autoHide: false, + // }); + // } - try { - const delres = await MediaLibrary.deleteAssetsAsync( - filesToDelete.map((f) => f.id) - ); + // try { + // const delres = await MediaLibrary.deleteAssetsAsync( + // filesToDelete.map((f) => f.id) + // ); - Toast.show({ - type: 'info', - text1: 'deleteAssetsAsync', - text2: JSON.stringify(delres), - autoHide: false, - }); - } catch (error) { - console.log("🚀 ~ onDone ~ error:", error) - Toast.show({ - type: 'error', - text1: 'deleteAssetsAsync', - text2: JSON.stringify(error), - autoHide: false, - }); - } + // Toast.show({ + // type: 'info', + // text1: 'deleteAssetsAsync', + // text2: JSON.stringify(delres), + // autoHide: false, + // }); + // } catch (error) { + // console.log("🚀 ~ onDone ~ error:", error) + // Toast.show({ + // type: 'error', + // text1: 'deleteAssetsAsync', + // text2: JSON.stringify(error), + // autoHide: false, + // }); + // } - try { - const res = Promise.all( - filesToDelete.map((f) => - FileSystem.deleteAsync(f.uri, { idempotent: true }) - ) - ); - Toast.show({ - type: 'info', - text1: 'FileSystemDelete', - text2: JSON.stringify(res), - autoHide: false, - }); - } catch (error) { - console.log("🚀 ~ onDone ~ error:", error) - Toast.show({ - type: 'error', - text1: 'FileSystemDelete', - text2: JSON.stringify(error), - autoHide: false, - }); - } + // try { + // const res = Promise.all( + // filesToDelete.map((f) => + // FileSystem.deleteAsync(f.uri, { idempotent: true }) + // ) + // ); + // Toast.show({ + // type: 'info', + // text1: 'FileSystemDelete', + // text2: JSON.stringify(res), + // autoHide: false, + // }); + // } catch (error) { + // console.log("🚀 ~ onDone ~ error:", error) + // Toast.show({ + // type: 'error', + // text1: 'FileSystemDelete', + // text2: JSON.stringify(error), + // autoHide: false, + // }); + // } try { const album = await MediaLibrary.createAlbumAsync( @@ -288,8 +288,8 @@ export function UploadProgress({ } const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); Toast.show({ - type: 'info', - text1: 'deleteAlbumsAsync', + type: 'success', + text1: 'Pictures deleted succesfully.', text2: JSON.stringify(deleteResult), autoHide: false, });