diff --git a/src/components/tasks/partials/attachments.vue b/src/components/tasks/partials/attachments.vue index 530fe50b9..0dd18c0f4 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 2ed932595..806635d01 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, + }) + } }, })