Fix sort order when marking a task as done from the overview

This commit is contained in:
kolaente 2020-09-28 20:37:06 +02:00
parent 21968ab86d
commit 0440c2cbed
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -168,31 +168,18 @@ export default {
this.error(e, this) this.error(e, this)
}) })
}, },
sortTasks() {
if (this.tasks === null || this.tasks === []) {
return
}
return this.tasks.sort(function (a, b) {
if (a.done < b.done)
return -1
if (a.done > b.done)
return 1
if (a.id > b.id)
return -1
if (a.id < b.id)
return 1
return 0
})
},
updateTasks(updatedTask) { updateTasks(updatedTask) {
for (const t in this.tasks) { for (const t in this.tasks) {
if (this.tasks[t].id === updatedTask.id) { if (this.tasks[t].id === updatedTask.id) {
this.$set(this.tasks, t, updatedTask) this.$set(this.tasks, t, updatedTask)
// Move the task to the end of the done tasks if it is now done
if (updatedTask.done) {
this.tasks.splice(t, 1)
this.tasks.push(updatedTask)
}
break break
} }
} }
this.sortTasks()
}, },
}, },
} }