From 428e22dc19fd4f1dacfcb301ae8934935524a3c3 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 28 Oct 2022 12:20:22 -0700 Subject: [PATCH] Fix shared album list --- src/components/frame/Photo.vue | 6 ++++-- src/components/frame/Tag.vue | 7 ++++++- src/components/modal/AlbumPicker.vue | 5 ++--- src/services/FileUtils.ts | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/components/frame/Photo.vue b/src/components/frame/Photo.vue index 0d7bb5cb..3758b46e 100644 --- a/src/components/frame/Photo.vue +++ b/src/components/frame/Photo.vue @@ -43,7 +43,7 @@ import { Component, Prop, Emit, Mixins, Watch } from "vue-property-decorator"; import { IDay, IPhoto } from "../../types"; -import { getPreviewUrl } from "../../services/FileUtils"; +import { getPhotosPreviewUrl, getPreviewUrl } from "../../services/FileUtils"; import errorsvg from "../../assets/error.svg"; import GlobalMixin from "../../mixins/GlobalMixin"; @@ -122,7 +122,9 @@ export default class Photo extends Mixins(GlobalMixin) { ) - 1; } - return getPreviewUrl(this.data.fileid, this.data.etag, false, size); + const fun = + this.$route.name === "albums" ? getPhotosPreviewUrl : getPreviewUrl; + return fun(this.data.fileid, this.data.etag, false, size); } /** Set src with overlay face rect */ diff --git a/src/components/frame/Tag.vue b/src/components/frame/Tag.vue index 42c6aca7..cca3c125 100644 --- a/src/components/frame/Tag.vue +++ b/src/components/frame/Tag.vue @@ -36,7 +36,7 @@ import { Component, Prop, Watch, Mixins, Emit } from "vue-property-decorator"; import { IAlbum, IPhoto, ITag } from "../../types"; import { generateUrl } from "@nextcloud/router"; -import { getPreviewUrl } from "../../services/FileUtils"; +import { getPhotosPreviewUrl, getPreviewUrl } from "../../services/FileUtils"; import { getCurrentUser } from "@nextcloud/auth"; import { NcCounterBubble } from "@nextcloud/vue"; @@ -86,6 +86,11 @@ export default class Tag extends Mixins(GlobalMixin) { "/apps/memories/api/faces/preview/" + this.data.fileid ); } + + if (this.isAlbum) { + return getPhotosPreviewUrl(fileid, etag, true, 256); + } + return getPreviewUrl(fileid, etag, true, 256); } diff --git a/src/components/modal/AlbumPicker.vue b/src/components/modal/AlbumPicker.vue index 44adf8c0..e05653f1 100644 --- a/src/components/modal/AlbumPicker.vue +++ b/src/components/modal/AlbumPicker.vue @@ -88,6 +88,7 @@ import ImageMultiple from "vue-material-design-icons/ImageMultiple.vue"; import { NcButton, NcListItem, NcLoadingIcon } from "@nextcloud/vue"; import { generateUrl } from "@nextcloud/router"; +import { getPhotosPreviewUrl } from "../../services/FileUtils"; import { IAlbum } from "../../types"; import axios from "@nextcloud/axios"; @@ -102,9 +103,7 @@ import axios from "@nextcloud/axios"; }, filters: { toCoverUrl(fileId: string) { - return generateUrl( - `/apps/photos/api/v1/preview/${fileId}?x=${256}&y=${256}` - ); + return getPhotosPreviewUrl(Number(fileId), "unknown", true, 256); }, }, }) diff --git a/src/services/FileUtils.ts b/src/services/FileUtils.ts index 8c76884d..6d4bb81f 100644 --- a/src/services/FileUtils.ts +++ b/src/services/FileUtils.ts @@ -133,6 +133,7 @@ const genFileInfo = function (obj) { return fileInfo; }; +/** Get preview URL from Nextcloud core */ const getPreviewUrl = function ( fileid: number, etag: string, @@ -145,10 +146,24 @@ const getPreviewUrl = function ( ); }; +/** Get the preview URL from the photos app */ +const getPhotosPreviewUrl = function ( + fileid: number, + etag: string, + square: boolean, + size: number +): string { + const a = square ? "0" : "1"; + return generateUrl( + `/apps/photos/api/v1/preview/${fileid}?c=${etag}&x=${size}&y=${size}&forceIcon=0&a=${a}` + ); +}; + export { encodeFilePath, extractFilePaths, sortCompare, genFileInfo, getPreviewUrl, + getPhotosPreviewUrl, };