From 05e55e27ec1793910175f7a2cc1b1401d4f25db5 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 9 Mar 2023 14:48:18 -0800 Subject: [PATCH] sidebar: fix for albums and shares (fix #320) --- lib/Controller/ImageController.php | 18 ++--- src/App.vue | 9 ++- src/components/Metadata.vue | 2 +- src/components/Sidebar.vue | 101 ++++++++++++++++++++++++++--- src/components/modal/Modal.vue | 4 +- src/components/viewer/Viewer.vue | 10 +-- src/main.ts | 4 +- 7 files changed, 121 insertions(+), 27 deletions(-) diff --git a/lib/Controller/ImageController.php b/lib/Controller/ImageController.php index 0496d8f7..3a3c00dc 100644 --- a/lib/Controller/ImageController.php +++ b/lib/Controller/ImageController.php @@ -193,15 +193,17 @@ class ImageController extends ApiBase // Get the image info $info = $this->timelineQuery->getInfoById($file->getId(), $basic); - // Get list of tags for this file - if ($tags) { - $info['tags'] = $this->getTags($file->getId()); - } + // Allow these ony for logged in users + if (null !== $this->userSession->getUser()) { + // Get list of tags for this file + if ($tags) { + $info['tags'] = $this->getTags($file->getId()); + } - // Get latest exif data if requested - // Allow this ony for logged in users - if ($current && null !== $this->userSession->getUser()) { - $info['current'] = Exif::getExifFromFile($file); + // Get latest exif data if requested + if ($current) { + $info['current'] = Exif::getExifFromFile($file); + } } return new JSONResponse($info, Http::STATUS_OK); diff --git a/src/App.vue b/src/App.vue index ed1947db..8d7c511a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -191,6 +191,11 @@ export default defineComponent({ // Register sidebar metadata tab const OCA = globalThis.OCA; if (OCA.Files && OCA.Files.Sidebar) { + const pf = (fileInfo) => { + fileInfo.fileid = Number(fileInfo.id); + return fileInfo; + }; + OCA.Files.Sidebar.registerTab( new OCA.Files.Sidebar.Tab({ id: "memories-metadata", @@ -201,10 +206,10 @@ export default defineComponent({ this.metadataComponent?.$destroy?.(); this.metadataComponent = new Vue(Metadata as any); this.metadataComponent.$mount(el); - this.metadataComponent.update(fileInfo); + this.metadataComponent.update(pf(fileInfo)); }, update(fileInfo) { - this.metadataComponent.update(fileInfo); + this.metadataComponent.update(pf(fileInfo)); }, destroy() { this.metadataComponent?.$destroy?.(); diff --git a/src/components/Metadata.vue b/src/components/Metadata.vue index ce707fab..c9968051 100644 --- a/src/components/Metadata.vue +++ b/src/components/Metadata.vue @@ -308,7 +308,7 @@ export default defineComponent({ this.exif = {}; const state = this.state; - const url = API.Q(API.IMAGE_INFO(fileInfo.id), "tags=1"); + const url = API.Q(API.IMAGE_INFO(fileInfo.fileid), "tags=1"); const res = await axios.get(url); if (state !== this.state) return; diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index fb3d874d..6ecaf733 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -1,18 +1,46 @@