fix: remove side effect from computed

was firing a commit
This commit is contained in:
Dominik Pschenitschni 2021-10-11 19:17:15 +02:00
parent 427f18d59e
commit 18c31482df
No known key found for this signature in database
GPG key ID: B257AC0149F43A77

View file

@ -508,6 +508,12 @@ export default {
handler: 'loadTask', handler: 'loadTask',
immediate: true, immediate: true,
}, },
parent: {
handler(parent) {
this.$store.commit(CURRENT_LIST, parent !== null ? parent.list : this.currentList)
},
immediate: true,
},
}, },
computed: { computed: {
taskId() { taskId() {
@ -529,9 +535,7 @@ export default {
return null return null
} }
const list = this.$store.getters['namespaces/getListAndNamespaceById'](this.task.listId) return this.$store.getters['namespaces/getListAndNamespaceById'](this.task.listId)
this.$store.commit(CURRENT_LIST, list !== null ? list.list : this.currentList)
return list
}, },
canWrite() { canWrite() {
return typeof this.task !== 'undefined' && typeof this.task.maxRight !== 'undefined' && this.task.maxRight > rights.READ return typeof this.task !== 'undefined' && typeof this.task.maxRight !== 'undefined' && this.task.maxRight > rights.READ
@ -599,15 +603,15 @@ export default {
this.activeFields.attachments = this.task.attachments.length > 0 this.activeFields.attachments = this.task.attachments.length > 0
this.activeFields.relatedTasks = Object.keys(this.task.relatedTasks).length > 0 this.activeFields.relatedTasks = Object.keys(this.task.relatedTasks).length > 0
}, },
saveTask(showNotification = true, undoCallback = null) { async saveTask(showNotification = true, undoCallback = null) {
if (!this.canWrite) { if (!this.canWrite) {
return return
} }
// We're doing the whole update in a nextTick because sometimes race conditions can occur when // We're doing the whole update in a nextTick because sometimes race conditions can occur when
// setting the due date on mobile which leads to no due date change being saved. // setting the due date on mobile which leads to no due date change being saved.
this.$nextTick(() => { await this.$nextTick()
this.task.hexColor = this.taskColor this.task.hexColor = this.taskColor
// If no end date is being set, but a start date and due date, // If no end date is being set, but a start date and due date,
@ -616,9 +620,8 @@ export default {
this.task.endDate = this.task.dueDate this.task.endDate = this.task.dueDate
} }
this.$store.dispatch('tasks/update', this.task) try {
.then(r => { this.task = await this.$store.dispatch('tasks/update', this.task)
this.task = r
this.setActiveFields() this.setActiveFields()
if (!showNotification) { if (!showNotification) {
@ -633,11 +636,9 @@ export default {
}] }]
} }
this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions) this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
}) } catch(e) {
.catch(e => {
this.$message.error(e) this.$message.error(e)
}) }
})
}, },
setFieldActive(fieldName) { setFieldActive(fieldName) {
this.activeFields[fieldName] = true this.activeFields[fieldName] = true
@ -692,9 +693,9 @@ export default {
this.saveTask() this.saveTask()
} }
}, },
changeList(list) { async changeList(list) {
this.task.listId = list.id this.task.listId = list.id
this.saveTask() await this.saveTask()
this.$store.commit('kanban/removeTaskInBucket', this.task) this.$store.commit('kanban/removeTaskInBucket', this.task)
}, },
toggleFavorite() { toggleFavorite() {