Fixed: Sort by Next Airing will always keep empty values at the bottom

pull/3113/head
Mark McDowall 10 years ago
parent ca9c6c651f
commit a5d7809b72

@ -81,8 +81,8 @@ define(
} }
return function (left, right) { return function (left, right) {
var l = sortValue(left, sortKey); var l = sortValue(left, sortKey, order);
var r = sortValue(right, sortKey); var r = sortValue(right, sortKey, order);
var t; var t;
if (order === 1) { if (order === 1) {
@ -94,8 +94,8 @@ define(
if (l === r) { if (l === r) {
if (secondarySorting) { if (secondarySorting) {
var ls = secondarySorting.sortValue(left, secondarySorting.key); var ls = secondarySorting.sortValue(left, secondarySorting.key, order);
var rs = secondarySorting.sortValue(right, secondarySorting.key); var rs = secondarySorting.sortValue(right, secondarySorting.key, order);
var ts; var ts;
if (secondarySorting.order === 1) { if (secondarySorting.order === 1) {

@ -62,21 +62,19 @@ define(
sortMappings: { sortMappings: {
'title' : { sortKey: 'sortTitle' }, 'title' : { sortKey: 'sortTitle' },
'nextAiring' : { 'nextAiring' : {
sortValue: function (model, attr) { sortValue: function (model, attr, order) {
var nextAiring = model.get(attr); var nextAiring = model.get(attr);
if (nextAiring) {
return moment(nextAiring).unix();
}
var previousAiring = model.get(attr.replace('nextAiring', 'previousAiring')); if (nextAiring) {
return moment(nextAiring).unix();
}
if (previousAiring) { if (order === 1) {
return 10000000000 - moment(previousAiring).unix(); return 0;
} }
return Number.MAX_VALUE; return Number.MAX_VALUE;
} }
}, },
percentOfEpisodes: { percentOfEpisodes: {

Loading…
Cancel
Save