Fixed: Sorting by timeleft on Activity: Queue

This commit is contained in:
Mark McDowall 2015-07-16 22:57:10 -07:00
parent 346d7f3cf4
commit ea19020015
1 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,7 @@ var PageableCollection = require('backbone.pageable');
var QueueModel = require('./QueueModel'); var QueueModel = require('./QueueModel');
var FormatHelpers = require('../../Shared/FormatHelpers'); var FormatHelpers = require('../../Shared/FormatHelpers');
var AsSortedCollection = require('../../Mixins/AsSortedCollection'); var AsSortedCollection = require('../../Mixins/AsSortedCollection');
var moment = require('moment');
require('../../Mixins/backbone.signalr.mixin'); require('../../Mixins/backbone.signalr.mixin');
@ -11,7 +12,8 @@ var QueueCollection = PageableCollection.extend({
model : QueueModel, model : QueueModel,
state : { state : {
pageSize : 15 pageSize : 15,
sortKey: 'timeleft'
}, },
mode : 'client', mode : 'client',
@ -45,6 +47,18 @@ var QueueCollection = PageableCollection.extend({
return episode.get('title'); return episode.get('title');
} }
},
timeleft : {
sortValue : function(model, attr) {
var eta = model.get('estimatedCompletionTime');
if (eta) {
return moment(eta).unix();
}
return Number.MAX_VALUE;
}
} }
} }
}); });