From a5d7809b72a55adddfaa61d4caa2c7639d85773b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 14 Dec 2014 09:42:30 -0800 Subject: [PATCH] Fixed: Sort by Next Airing will always keep empty values at the bottom --- src/UI/Mixins/AsSortedCollection.js | 8 ++++---- src/UI/Series/SeriesCollection.js | 26 ++++++++++++-------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/UI/Mixins/AsSortedCollection.js b/src/UI/Mixins/AsSortedCollection.js index 8bf11d313..bf0039952 100644 --- a/src/UI/Mixins/AsSortedCollection.js +++ b/src/UI/Mixins/AsSortedCollection.js @@ -81,8 +81,8 @@ define( } return function (left, right) { - var l = sortValue(left, sortKey); - var r = sortValue(right, sortKey); + var l = sortValue(left, sortKey, order); + var r = sortValue(right, sortKey, order); var t; if (order === 1) { @@ -94,8 +94,8 @@ define( if (l === r) { if (secondarySorting) { - var ls = secondarySorting.sortValue(left, secondarySorting.key); - var rs = secondarySorting.sortValue(right, secondarySorting.key); + var ls = secondarySorting.sortValue(left, secondarySorting.key, order); + var rs = secondarySorting.sortValue(right, secondarySorting.key, order); var ts; if (secondarySorting.order === 1) { diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 99dd502c8..e47f2def9 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -62,21 +62,19 @@ define( sortMappings: { 'title' : { sortKey: 'sortTitle' }, 'nextAiring' : { - sortValue: function (model, attr) { - var nextAiring = model.get(attr); - - if (nextAiring) { - return moment(nextAiring).unix(); - } - - var previousAiring = model.get(attr.replace('nextAiring', 'previousAiring')); - - if (previousAiring) { - return 10000000000 - moment(previousAiring).unix(); - } + sortValue: function (model, attr, order) { + var nextAiring = model.get(attr); - return Number.MAX_VALUE; - } + if (nextAiring) { + return moment(nextAiring).unix(); + } + + if (order === 1) { + return 0; + } + + return Number.MAX_VALUE; + } }, percentOfEpisodes: {