diff --git a/src/models/Torrent.ts b/src/models/Torrent.ts index 26c531f8..15cd4364 100644 --- a/src/models/Torrent.ts +++ b/src/models/Torrent.ts @@ -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 diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 96d4eb4a..5df63797 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -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