From 2ebbda56f6f45091acc16f066771d9b5e9363995 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 5 Jun 2025 13:27:07 -0700 Subject: [PATCH] Resolve delete on upload for android. --- app.json | 2 +- .../upload-progress-local.component.jsx | 35 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app.json b/app.json index 6683045..3384c76 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,7 @@ "slug": "imexmobile", "version": "1.7.0", "extra": { - "expover": "1", + "expover": "2", "eas": { "projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b" } diff --git a/components/upload-progress-local/upload-progress-local.component.jsx b/components/upload-progress-local/upload-progress-local.component.jsx index 3840823..f8a959c 100644 --- a/components/upload-progress-local/upload-progress-local.component.jsx +++ b/components/upload-progress-local/upload-progress-local.component.jsx @@ -5,6 +5,7 @@ import { ActivityIndicator, Alert, Modal, + Platform, StyleSheet, Text, View, @@ -61,22 +62,32 @@ export function UploadProgress({ }); if (deleteAfterUpload) { try { - await MediaLibrary.deleteAssetsAsync(data); + if (Platform.OS === "android") { + //Create a new asset with the first file to delete. + // console.log('Trying new delete.'); + await MediaLibrary.getPermissionsAsync(false); - 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, + 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); + + //Delete the album. + + //This defaults to delete all assets in the album. + } else { + await MediaLibrary.deleteAssetsAsync(data.map((f) => f.id)); } - const deleteResult = await MediaLibrary.deleteAlbumsAsync(album); } catch (error) { console.log("Unable to delete picture.", error); Sentry.captureException(error);