From 5181b0170cf6df7ece86a59a2ec176210dabfd8d Mon Sep 17 00:00:00 2001 From: rainu Date: Mon, 4 Nov 2024 09:41:38 +0100 Subject: [PATCH] fix display issue for images in subdirectory --- src/components/image/ImageItem.vue | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/image/ImageItem.vue b/src/components/image/ImageItem.vue index 9b067d9..082dab3 100644 --- a/src/components/image/ImageItem.vue +++ b/src/components/image/ImageItem.vue @@ -52,8 +52,25 @@ export default defineComponent({ return } + let parentDirectory = this.baseDir + let name = this.image.uri.name + const parents = this.image.uri.name.split('/') + if(parents.length > 1) { + name = parents.pop() || '' + for (let parent of parents) { + try { + parentDirectory = await parentDirectory.getDirectoryHandle(parent) + } catch (e: Error) { + if (e.name !== 'NotFoundError') { + console.error(e) + } + return + } + } + } + try { - const file = await this.baseDir.getFileHandle(this.image.uri.name) + const file = await parentDirectory.getFileHandle(name) this.url = URL.createObjectURL(await file.getFile()) } catch (e: Error) { if (e.name !== 'NotFoundError') {