From 17618301bc759f1ede9d3cd419df4a02ee6e1828 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 29 Sep 2024 11:54:20 +0200 Subject: [PATCH] Revert "chore(attachments): refactor building image preview" This reverts commit e70f5bcce39ae19060be62aec8b75f75c26d1b9e. --- .../components/tasks/partials/Attachments.vue | 6 +- .../components/tasks/partials/FilePreview.vue | 8 +- .../components/tasks/partials/KanbanCard.vue | 2 +- frontend/src/models/attachment.ts | 4 - frontend/src/services/attachment.ts | 9 +- pkg/models/task_attachment.go | 113 +----------------- pkg/routes/api/v1/task_attachment.go | 15 ++- 7 files changed, 26 insertions(+), 131 deletions(-) diff --git a/frontend/src/components/tasks/partials/Attachments.vue b/frontend/src/components/tasks/partials/Attachments.vue index d6ba21dae..dc84aaa27 100644 --- a/frontend/src/components/tasks/partials/Attachments.vue +++ b/frontend/src/components/tasks/partials/Attachments.vue @@ -180,7 +180,7 @@ import ProgressBar from '@/components/misc/ProgressBar.vue' import BaseButton from '@/components/base/BaseButton.vue' import AttachmentService from '@/services/attachment' -import {canPreview} from '@/models/attachment' +import {SUPPORTED_IMAGE_SUFFIX} from '@/models/attachment' import type {IAttachment} from '@/modelTypes/IAttachment' import type {ITask} from '@/modelTypes/ITask' @@ -274,6 +274,10 @@ async function viewOrDownload(attachment: IAttachment) { } } +function canPreview(attachment: IAttachment): boolean { + return SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.toLowerCase().endsWith(suffix)) +} + const copy = useCopyToClipboard() function copyUrl(attachment: IAttachment) { diff --git a/frontend/src/components/tasks/partials/FilePreview.vue b/frontend/src/components/tasks/partials/FilePreview.vue index 4edde7e13..306a2915e 100644 --- a/frontend/src/components/tasks/partials/FilePreview.vue +++ b/frontend/src/components/tasks/partials/FilePreview.vue @@ -22,7 +22,7 @@ import {ref, shallowReactive, watchEffect} from 'vue' import AttachmentService from '@/services/attachment' import type {IAttachment} from '@/modelTypes/IAttachment' -import {canPreview} from '@/models/attachment' +import {SUPPORTED_IMAGE_SUFFIX} from '@/models/attachment' const props = defineProps<{ modelValue?: IAttachment @@ -33,9 +33,13 @@ const blobUrl = ref(undefined) watchEffect(async () => { if (props.modelValue && canPreview(props.modelValue)) { - blobUrl.value = await attachmentService.getBlobUrl(props.modelValue, PREVIEW_SIZE.MD) + blobUrl.value = await attachmentService.getBlobUrl(props.modelValue) } }) + +function canPreview(attachment: IAttachment): boolean { + return SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.toLowerCase().endsWith(suffix)) +}