From ee3965eae9f2210a5f397d81327128d36b22b751 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 3 Oct 2022 15:23:34 +0200 Subject: [PATCH] chore(task): move cover image setter to store --- src/components/tasks/partials/attachments.vue | 7 ++----- src/stores/tasks.ts | 7 +++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/tasks/partials/attachments.vue b/src/components/tasks/partials/attachments.vue index 530fe50b..0dd18c0f 100644 --- a/src/components/tasks/partials/attachments.vue +++ b/src/components/tasks/partials/attachments.vue @@ -83,7 +83,7 @@ class="attachment-info-meta-button" @click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)" > - {{ + {{ task.coverImageAttachmentId === a.id ? $t('task.attachment.unsetAsCover') : $t('task.attachment.setAsCover') @@ -257,10 +257,7 @@ function copyUrl(attachment: IAttachment) { } async function setCoverImage(attachment: IAttachment | null) { - const task = await taskStore.update({ - ...props.task, - coverImageAttachmentId: attachment ? attachment.id : 0, - }) + const task = await taskStore.setCoverImage(props.task, attachment) emit('task-changed', task) success({message: t('task.attachment.successfullyChangedCoverImage')}) } diff --git a/src/stores/tasks.ts b/src/stores/tasks.ts index 2ed93259..806635d0 100644 --- a/src/stores/tasks.ts +++ b/src/stores/tasks.ts @@ -409,6 +409,13 @@ export const useTaskStore = defineStore('task', { cancel() } }, + + async setCoverImage(task: ITask, attachment: IAttachment | null) { + return this.update({ + ...task, + coverImageAttachmentId: attachment ? attachment.id : 0, + }) + } }, })