diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-20 10:58:58 +0100 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-11-20 10:58:58 +0100 |
commit | 193bd948d7e628f1b0544f9b7b0304cdd1067a4a (patch) | |
tree | 0d7a7442977a4ac4c573a3d496a14fdc4393826b /js/controller/ContentController.js | |
parent | a2054d20b7b9616b7cb4cbf8b66bfb7d4c520246 (diff) |
fix multiple bugs
Diffstat (limited to 'js/controller/ContentController.js')
-rw-r--r-- | js/controller/ContentController.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/js/controller/ContentController.js b/js/controller/ContentController.js index e9fb0b6fd..26d6e9611 100644 --- a/js/controller/ContentController.js +++ b/js/controller/ContentController.js @@ -9,10 +9,9 @@ */ app.controller('ContentController', function (Publisher, FeedResource, ItemResource, SettingsResource, data, - $route, $routeParams, FEED_TYPE) { + $route, $routeParams, FEED_TYPE, ITEM_AUTO_PAGE_SIZE, Loading) { 'use strict'; - // dont cache items across multiple route changes ItemResource.clear(); // distribute data to models based on key @@ -20,7 +19,14 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data, this.isAutoPagingEnabled = true; - this.isNothingMoreToAutoPage = false; + + // the interface should show a hint if there are not enough items sent so + // it's assumed that theres nothing to autpage + if (ItemResource.size() >= ITEM_AUTO_PAGE_SIZE) { + this.isNothingMoreToAutoPage = false; + } else { + this.isNothingMoreToAutoPage = true; + } this.getItems = function () { return ItemResource.getAll(); @@ -107,6 +113,10 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data, }; this.autoPage = function () { + if (this.isNothingMoreToAutoPage) { + return; + } + // in case a subsequent autopage request comes in wait until // the current one finished and execute a request immediately afterwards if (!this.isAutoPagingEnabled) { @@ -120,12 +130,16 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data, var type = $route.current.$$route.type; var id = $routeParams.id; var oldestFirst = SettingsResource.get('oldestFirst'); + var showAll = SettingsResource.get('showAll'); var self = this; - ItemResource.autoPage(type, id, oldestFirst).success(function (data) { + Loading.setLoading('autopaging', true); + + ItemResource.autoPage(type, id, oldestFirst, showAll) + .success(function (data) { Publisher.publishAll(data); - if (data.items.length > 0) { + if (data.items.length >= ITEM_AUTO_PAGE_SIZE) { self.isAutoPagingEnabled = true; } else { self.isNothingMoreToAutoPage = true; @@ -136,6 +150,8 @@ function (Publisher, FeedResource, ItemResource, SettingsResource, data, } }).error(function () { self.isAutoPagingEnabled = true; + }).finally(function () { + Loading.setLoading('autopaging', false); }); }; |