fix: sort tasks correctly by due date

This commit is contained in:
kolaente 2022-01-30 12:01:37 +01:00
parent 7135288800
commit 9e7c258347
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -121,12 +121,22 @@ export default {
// soonest before the later ones. // soonest before the later ones.
// We can't use the api sorting here because that sorts tasks with a due date after // We can't use the api sorting here because that sorts tasks with a due date after
// ones without a due date. // ones without a due date.
return [...this.tasks].sort((a, b) => {
const sortByDueDate = b.dueDate - a.dueDate const tasksWithDueDate = [...this.tasks]
.filter(t => t.dueDate !== null)
.sort((a, b) => {
const sortByDueDate = a.dueDate - b.dueDate
return sortByDueDate === 0 return sortByDueDate === 0
? b.id - a.id ? b.id - a.id
: sortByDueDate : sortByDueDate
}) })
const tasksWithoutDueDate = [...this.tasks]
.filter(t => t.dueDate === null)
return [
...tasksWithDueDate,
...tasksWithoutDueDate,
]
}, },
hasTasks() { hasTasks() {
return this.tasks && this.tasks.length > 0 return this.tasks && this.tasks.length > 0