Skip to content

Commit

Permalink
Implement calculating the manual sort order
Browse files Browse the repository at this point in the history
  • Loading branch information
raimund-schluessler committed Apr 16, 2019
1 parent 969153f commit e8ea841
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/models/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ export default class Task {
this._modified = this.vtodo.getFirstPropertyValue('last-modified')
this._created = this.vtodo.getFirstPropertyValue('created')

let sortOrder = this.vtodo.getFirstPropertyValue('x-apple-sort-order')
if (sortOrder === null) {
sortOrder = this._created.subtractDate(
new ICAL.Time({
year: 2001,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
isDate: false
})
).toSeconds()
}
this._sortOrder = sortOrder

this._searchQuery = ''
this._matchesSearchQuery = true
}
Expand Down Expand Up @@ -450,6 +466,29 @@ export default class Task {
this._created = this.vtodo.getFirstPropertyValue('created')
}

get sortOrder() {
return this._sortOrder
}

set sortOrder(sortOrder) {
if (sortOrder === null) {
sortOrder = this._created.subtractDate(
new ICAL.Time({
year: 2001,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
isDate: false
})
).toSeconds()
}
this.vtodo.updatePropertyWithValue('x-apple-sort-order', sortOrder)
this.updateLastModified()
this._sortOrder = sortOrder
}

/**
* Checks if the task matches the search query
*
Expand Down

0 comments on commit e8ea841

Please sign in to comment.