chore(task): move cover image setter to store

This commit is contained in:
kolaente 2022-10-03 15:23:34 +02:00
parent fad72e091b
commit ee3965eae9
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 9 additions and 5 deletions

View File

@ -83,7 +83,7 @@
class="attachment-info-meta-button" class="attachment-info-meta-button"
@click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)" @click.prevent.stop="setCoverImage(task.coverImageAttachmentId === a.id ? null : a)"
> >
{{ {{
task.coverImageAttachmentId === a.id task.coverImageAttachmentId === a.id
? $t('task.attachment.unsetAsCover') ? $t('task.attachment.unsetAsCover')
: $t('task.attachment.setAsCover') : $t('task.attachment.setAsCover')
@ -257,10 +257,7 @@ function copyUrl(attachment: IAttachment) {
} }
async function setCoverImage(attachment: IAttachment | null) { async function setCoverImage(attachment: IAttachment | null) {
const task = await taskStore.update({ const task = await taskStore.setCoverImage(props.task, attachment)
...props.task,
coverImageAttachmentId: attachment ? attachment.id : 0,
})
emit('task-changed', task) emit('task-changed', task)
success({message: t('task.attachment.successfullyChangedCoverImage')}) success({message: t('task.attachment.successfullyChangedCoverImage')})
} }

View File

@ -409,6 +409,13 @@ export const useTaskStore = defineStore('task', {
cancel() cancel()
} }
}, },
async setCoverImage(task: ITask, attachment: IAttachment | null) {
return this.update({
...task,
coverImageAttachmentId: attachment ? attachment.id : 0,
})
}
}, },
}) })