IO-2035 LMS Media.

This commit is contained in:
Patrick Fic
2022-08-30 12:26:22 -07:00
parent 64a31dc544
commit e25172f0bf
8 changed files with 1185 additions and 830 deletions

View File

@@ -13,8 +13,10 @@ import {
View,
} from "react-native";
import { Divider, ProgressBar } from "react-native-paper";
import Toast from "react-native-toast-message";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import * as Sentry from "sentry-expo";
import { logImEXEvent } from "../../firebase/firebase.analytics";
import { GET_DOC_SIZE_TOTALS } from "../../graphql/documents.queries";
import {
@@ -26,8 +28,6 @@ import {
selectCurrentUser,
} from "../../redux/user/user.selectors";
import { formatBytes, handleUpload } from "../../util/document-upload.utility";
import Toast from "react-native-toast-message";
import * as Sentry from "sentry-expo";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
@@ -205,16 +205,49 @@ export function UploadProgress({
try {
console.log("Trying to Delete", filesToDelete);
if (Platform.OS === "android") {
await Promise.all(
filesToDelete.map(async (f) =>
MediaLibrary.removeAssetsFromAlbumAsync(f, f.albumId)
)
//Create a new asset with the first file to delete.
console.log("Trying new delete.");
const delres = await MediaLibrary.removeAssetsFromAlbumAsync(
filesToDelete,
filesToDelete[0].albumId
);
console.log(
"🚀 ~ file: upload-progress.component.jsx ~ line 220 ~ delres",
delres
);
// const album = await MediaLibrary.createAlbumAsync(
// "Deleted",
// filesToDelete.pop(),
// false
// );
// console.log(
// "🚀 ~ file: upload-progress.component.jsx ~ line 215 ~ album",
// album
// );
// //Move the rest.
// const moveResult = await MediaLibrary.addAssetsToAlbumAsync(
// filesToDelete,
// album.id,
// false
// );
// console.log(
// "🚀 ~ file: upload-progress.component.jsx ~ line 221 ~ moveResult",
// moveResult
// );
// //Delete the album.
// const deleteResult = await MediaLibrary.deleteAlbumsAsync(
// album.id,
// true
// );
// console.log(
// "🚀 ~ file: upload-progress.component.jsx ~ line 228 ~ deleteResult",
// deleteResult
// );
} else {
await MediaLibrary.deleteAssetsAsync(filesToDelete.map((f) => f.id));
}
console.log(
"Delete Result",
await MediaLibrary.deleteAssetsAsync(filesToDelete.map((f) => f.id))
);
} catch (error) {
console.log("Unable to delete picture.", error);
Sentry.Native.captureException(error);