Resolve delete on upload for android.

This commit is contained in:
Patrick Fic
2025-06-05 13:27:07 -07:00
parent 4797d4168b
commit 2ebbda56f6
2 changed files with 24 additions and 13 deletions

View File

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