mirror of
https://github.com/VueTorrent/VueTorrent.git
synced 2024-11-25 02:45:48 +03:00
perf: enable manual sort for priority (#845)
This commit is contained in:
parent
1bc4d81481
commit
3bf470b890
2 changed files with 11 additions and 2 deletions
|
@ -12,7 +12,7 @@ dayjs.extend(relativeTime)
|
|||
const durationFormat = 'D[d] H[h] m[m] s[s]'
|
||||
|
||||
export default class Torrent {
|
||||
static computedValues = ['globalSpeed', 'globalVolume']
|
||||
static computedValues = ['globalSpeed', 'globalVolume', 'priority']
|
||||
|
||||
added_on: string
|
||||
amount_left: number
|
||||
|
|
|
@ -253,7 +253,16 @@ export default {
|
|||
}
|
||||
|
||||
if (this.sort_options.isCustomSortEnabled) {
|
||||
torrents.sort((a, b) => a[this.sort_options.sort] - b[this.sort_options.sort] || a.added_on - b.added_on)
|
||||
if (this.sort_options.sort === 'priority') {
|
||||
torrents.sort((a, b) => {
|
||||
if (a.priority > 0 && b.priority > 0) return a.priority - b.priority
|
||||
else if (a.priority <= 0 && b.priority <= 0) return a.added_on - b.added_on
|
||||
else if (a.priority <= 0) return 1
|
||||
else return -1
|
||||
})
|
||||
} else {
|
||||
torrents.sort((a, b) => a[this.sort_options.sort] - b[this.sort_options.sort] || a.added_on - b.added_on)
|
||||
}
|
||||
if (this.sort_options.reverse) torrents.reverse()
|
||||
}
|
||||
return torrents
|
||||
|
|
Loading…
Reference in a new issue