summaryrefslogtreecommitdiffstats
path: root/js/public/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/public/app.js')
-rw-r--r--js/public/app.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/js/public/app.js b/js/public/app.js
index e314695ca..26680dea4 100644
--- a/js/public/app.js
+++ b/js/public/app.js
@@ -2730,6 +2730,8 @@ 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;
+ this._lastFeedChange = new Date().getTime();
}
Persistence.prototype.init = function() {
@@ -2760,21 +2762,35 @@ 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, lastChange, loading, params, successCallbackWrapper,
+ _this = this;
if (onSuccess == null) {
onSuccess = null;
}
onSuccess || (onSuccess = function() {});
if (offset === 0) {
loading = this._feedLoading;
+ this._lastFeedChange = new Date().getTime();
+ this._preventUselessAutoPageRequest = false;
} else {
loading = this._autoPageLoading;
}
loading.increase();
- successCallbackWrapper = function(data) {
- onSuccess(data);
- return loading.decrease();
- };
+ successCallbackWrapper = function() {};
+ lastChange = this._lastFeedChange;
+ (function(lastChange, offset) {
+ return successCallbackWrapper = function(data) {
+ console.log(data);
+ console.log(offset);
+ console.log(lastChange);
+ console.log(_this._lastFeedChange);
+ if (data.items.length === 0 && lastChange === _this._lastFeedChange && offset !== 0) {
+ _this._preventUselessAutoPageRequest = true;
+ }
+ onSuccess(data);
+ return loading.decrease();
+ };
+ })(lastChange, offset);
failureCallbackWrapper = function(data) {
return loading.decrease();
};
@@ -2788,7 +2804,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) {