summaryrefslogtreecommitdiffstats
path: root/js/public/app.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2013-12-20 17:24:50 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2013-12-20 17:25:01 +0100
commit67daf1074702f8ee8e0720c6f864bc4b8eb3780c (patch)
tree7b17318ad4a1ef70415589e152ebafbfa62bba86 /js/public/app.js
parentee9810ede5a5e3e10b214a771d0a58dcbb29bc36 (diff)
prevent multiple autopage requests, fix #201
Diffstat (limited to 'js/public/app.js')
-rw-r--r--js/public/app.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/js/public/app.js b/js/public/app.js
index e314695ca..c709dccab 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -1051,10 +1051,12 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._itemModel = _itemModel;
this._type = _type;
this._$rootScope = _$rootScope;
+ this._preventAutopage = false;
}
BusinessLayer.prototype.load = function(id) {
var _this = this;
+ this._preventAutopage = false;
this._$rootScope.$broadcast('loadingNewItems');
this._itemModel.clear();
this._persistence.getItems(this._type, id, 0, function() {
@@ -2730,6 +2732,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
this._config = _config;
this._activeFeed = _activeFeed;
this._$rootScope = _$rootScope;
+ this._preventUselessAutoPageRequest = false;
}
Persistence.prototype.init = function() {
@@ -2760,18 +2763,23 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
Persistence.prototype.getItems = function(type, id, offset, onSuccess) {
- var failureCallbackWrapper, loading, params, successCallbackWrapper;
+ var failureCallbackWrapper, loading, params, successCallbackWrapper,
+ _this = this;
if (onSuccess == null) {
onSuccess = null;
}
onSuccess || (onSuccess = function() {});
if (offset === 0) {
+ this._preventUselessAutoPageRequest = false;
loading = this._feedLoading;
} else {
loading = this._autoPageLoading;
}
loading.increase();
successCallbackWrapper = function(data) {
+ if (data.items.length === 0) {
+ _this._preventUselessAutoPageRequest = true;
+ }
onSuccess(data);
return loading.decrease();
};
@@ -2788,7 +2796,9 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
onSuccess: successCallbackWrapper,
onFailure: failureCallbackWrapper
};
- return this._request.get('news_items', params);
+ if (!this._preventUselessAutoPageRequest) {
+ return this._request.get('news_items', params);
+ }
};
Persistence.prototype.getNewItems = function(type, id, lastModified, onSuccess) {