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
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 9 additions and 5 deletions

View file

@ -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')})
}

View file

@ -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,
})
}
},
})