livephoto: fix iOS deletion
parent
d57ab66310
commit
9fe31c87b6
|
@ -207,6 +207,11 @@ class VideoController extends ApiBase
|
||||||
$liveFile = $files[0];
|
$liveFile = $files[0];
|
||||||
|
|
||||||
if ($liveFile instanceof File) {
|
if ($liveFile instanceof File) {
|
||||||
|
// Requested only JSON info
|
||||||
|
if ('json' === $this->request->getParam('format')) {
|
||||||
|
return new JSONResponse($lp);
|
||||||
|
}
|
||||||
|
|
||||||
$name = $liveFile->getName();
|
$name = $liveFile->getName();
|
||||||
$blob = $liveFile->getContent();
|
$blob = $liveFile->getContent();
|
||||||
$mime = $liveFile->getMimeType();
|
$mime = $liveFile->getMimeType();
|
||||||
|
|
|
@ -1213,7 +1213,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
|
||||||
*/
|
*/
|
||||||
async deleteFromViewWithAnimation(delPhotos: IPhoto[]) {
|
async deleteFromViewWithAnimation(delPhotos: IPhoto[]) {
|
||||||
// Only keep photos with day
|
// Only keep photos with day
|
||||||
delPhotos = delPhotos.filter((p) => p.d);
|
delPhotos = delPhotos.filter((p) => p?.d);
|
||||||
if (delPhotos.length === 0) return;
|
if (delPhotos.length === 0) return;
|
||||||
|
|
||||||
// Get all days that need to be updatd
|
// Get all days that need to be updatd
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import { getCurrentUser } from "@nextcloud/auth";
|
import { getCurrentUser } from "@nextcloud/auth";
|
||||||
import { showError } from "@nextcloud/dialogs";
|
import { showError } from "@nextcloud/dialogs";
|
||||||
import { translate as t } from "@nextcloud/l10n";
|
import { translate as t } from "@nextcloud/l10n";
|
||||||
|
import axios from "@nextcloud/axios";
|
||||||
|
|
||||||
import { IFileInfo, IPhoto } from "../../types";
|
import { IFileInfo, IPhoto } from "../../types";
|
||||||
import client from "../DavClient";
|
|
||||||
import { genFileInfo } from "../FileUtils";
|
import { genFileInfo } from "../FileUtils";
|
||||||
import { getAlbumFileInfos } from "./albums";
|
import { getAlbumFileInfos } from "./albums";
|
||||||
|
import * as utils from "../Utils";
|
||||||
|
import client from "../DavClient";
|
||||||
|
|
||||||
export const props = `
|
export const props = `
|
||||||
<oc:fileid />
|
<oc:fileid />
|
||||||
|
@ -195,10 +198,32 @@ export async function* deletePhotos(photos: IPhoto[]) {
|
||||||
|
|
||||||
const fileIdsSet = new Set(photos.map((p) => p.fileid));
|
const fileIdsSet = new Set(photos.map((p) => p.fileid));
|
||||||
|
|
||||||
|
// Get live photo data
|
||||||
|
const livePhotos = (
|
||||||
|
await Promise.all(
|
||||||
|
photos
|
||||||
|
.filter((p) => p.liveid && !p.liveid.startsWith("self__"))
|
||||||
|
.map(async (p) => {
|
||||||
|
const url = utils.getLivePhotoVideoUrl(p) + "&format=json";
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url);
|
||||||
|
const data = response.data;
|
||||||
|
fileIdsSet.add(data.fileid);
|
||||||
|
return {
|
||||||
|
fileid: data.fileid,
|
||||||
|
} as IPhoto;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
).filter((p) => p !== null) as IPhoto[];
|
||||||
|
|
||||||
// Get files data
|
// Get files data
|
||||||
let fileInfos: IFileInfo[] = [];
|
let fileInfos: IFileInfo[] = [];
|
||||||
try {
|
try {
|
||||||
fileInfos = await getFiles(photos);
|
fileInfos = await getFiles(photos.concat(livePhotos));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to get file info for files to delete", photos, e);
|
console.error("Failed to get file info for files to delete", photos, e);
|
||||||
showError(t("memories", "Failed to delete files."));
|
showError(t("memories", "Failed to delete files."));
|
||||||
|
|
Loading…
Reference in New Issue