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,45 +603,42 @@ 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
// If no end date is being set, but a start date and due date, this.task.hexColor = this.taskColor
// use the due date as the end date
if (this.task.endDate === null && this.task.startDate !== null && this.task.dueDate !== null) { // If no end date is being set, but a start date and due date,
this.task.endDate = this.task.dueDate // use the due date as the end date
if (this.task.endDate === null && this.task.startDate !== null && this.task.dueDate !== null) {
this.task.endDate = this.task.dueDate
}
try {
this.task = await this.$store.dispatch('tasks/update', this.task)
this.setActiveFields()
if (!showNotification) {
return
} }
this.$store.dispatch('tasks/update', this.task) let actions = []
.then(r => { if (undoCallback !== null) {
this.task = r actions = [{
this.setActiveFields() title: 'Undo',
callback: undoCallback,
if (!showNotification) { }]
return }
} this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
} catch(e) {
let actions = [] this.$message.error(e)
if (undoCallback !== null) { }
actions = [{
title: 'Undo',
callback: undoCallback,
}]
}
this.$message.success({message: this.$t('task.detail.updateSuccess')}, actions)
})
.catch(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() {