Fix most paging issues on first load.

This commit is contained in:
Leonardo Galli 2017-03-06 22:02:25 +01:00
parent 665832f0cc
commit 4640519438
2 changed files with 61 additions and 41 deletions

View File

@ -61,7 +61,7 @@ module.exports = Marionette.Layout.extend({
name : 'added',
label : 'Date Added',
cell : RelativeDateCell
},
},
{
name : "downloadedQuality",
label : "Downloaded",
@ -139,6 +139,7 @@ module.exports = Marionette.Layout.extend({
initialize : function() {
//this variable prevents us from showing the list before seriesCollection has been fetched the first time
this.seriesCollection = MoviesCollection.clone();
//debugger;
this.seriesCollection.bindSignalR();
var pageSize = parseInt(Config.getValue("pageSize")) || 10;
// this.seriesCollection.setPageSize(pageSize);
@ -191,7 +192,7 @@ module.exports = Marionette.Layout.extend({
}
});
this.seriesCollection.setPageSize(pageSize);
//this.seriesCollection.setPageSize(pageSize);
this.sortingOptions = {
@ -303,6 +304,12 @@ module.exports = Marionette.Layout.extend({
}
]
};
//this._showToolbar();
//debugger;
self = this;
setTimeout(function(){self._showToolbar();}, 0);//wtf???
//this._renderView();
},
onShow : function() {
@ -375,6 +382,7 @@ module.exports = Marionette.Layout.extend({
},
_showToolbar : function() {
//debugger;
if (this.toolbar.currentView) {
return;
}
@ -416,7 +424,7 @@ module.exports = Marionette.Layout.extend({
var movies = FullMovieCollection.models.length;
//instead of all the counters could do something like this with different query in the where...
//var releasedMovies = FullMovieCollection.where({ 'released' : this.model.get('released') });
// releasedMovies.length
// releasedMovies.length
var announced = 0;
var incinemas = 0;

View File

@ -13,6 +13,44 @@ var Config = require('../Config');
var pageSize = parseInt(Config.getValue("pageSize")) || 1000;
var filterModes = {
'all' : [
null,
null
],
'continuing' : [
'status',
'continuing'
],
'ended' : [
'status',
'ended'
],
'monitored' : [
'monitored',
true
],
'missing' : [
'downloaded',
false
],
'released' : [
"status",
"released",
//function(model) { return model.getStatus() == "released"; }
],
'announced' : [
"status",
"announced",
//function(model) { return model.getStatus() == "announced"; }
],
'cinemas' : [
"status",
"inCinemas",
//function(model) { return model.getStatus() == "inCinemas"; }
]
}//Hacky, I know
var Collection = PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/movie',
@ -122,43 +160,7 @@ var Collection = PageableCollection.extend({
return proxy.save();
},
filterModes : {
'all' : [
null,
null
],
'continuing' : [
'status',
'continuing'
],
'ended' : [
'status',
'ended'
],
'monitored' : [
'monitored',
true
],
'missing' : [
'downloaded',
false
],
'released' : [
"status",
"released",
//function(model) { return model.getStatus() == "released"; }
],
'announced' : [
"status",
"announced",
//function(model) { return model.getStatus() == "announced"; }
],
'cinemas' : [
"status",
"inCinemas",
//function(model) { return model.getStatus() == "inCinemas"; }
]
},
filterModes : filterModes,
sortMappings : {
title : {
@ -263,6 +265,16 @@ Collection = AsFilteredCollection.call(Collection);
Collection = AsSortedCollection.call(Collection);
Collection = AsPersistedStateCollection.call(Collection);
var data = ApiData.get('movie?page=1&pageSize='+pageSize+'&sortKey=sortTitle&sortDir=asc');
var filterMode = Config.getValue("series.filterMode", "all");
var sortKey = Config.getValue("movie.sortKey", "sortTitle");
var sortDir = Config.getValue("movie.sortDirection", -1);
var sortD = "asc";
if (sortDir == 1) {
sortD = "desc";
}
var values = filterModes[filterMode];
var data = ApiData.get("movie?page=1&pageSize={0}&sortKey={3}&sortDir={4}&filterKey={1}&filterValue={2}".format(pageSize, values[0], values[1], sortKey, sortD));
module.exports = new Collection(data.records, { full : false, state : { totalRecords : data.totalRecords} }).bindSignalR();