From a30aebb934bf35a58f08b3c9b196ecb4218fab56 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 15 Oct 2012 23:05:51 +0200 Subject: abort load request if a new feed is being loaded --- js/items.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/items.js b/js/items.js index 48ac53bdb..847647206 100644 --- a/js/items.js +++ b/js/items.js @@ -31,6 +31,7 @@ var News = News || {}; this._$articleList.scrollTop(0); this._$articleList.children('ul').children('.feed_item:eq(0)').addClass('viewed'); this._itemCache = new ItemCache(); + this._loadRequest = null; this._setScrollBottom(); $(window).resize(function(){ @@ -89,6 +90,10 @@ var News = News || {}; * @param onSuccessCallback a callback that is executed when the loading succeeded */ Items.prototype.load = function(type, id, onSuccessCallback) { + if(this._loadRequest !== null){ + this._loadRequest.abort(); + } + this._lastActiveFeedId = id; this._lastActiveFeedType = type; @@ -102,7 +107,7 @@ var News = News || {}; this._$articleList.addClass('loading'); this._$articleList.children('ul').hide(); - $.post(OC.filePath('news', 'ajax', 'loadfeed.php'), data, function(jsonData) { + this._loadRequest = $.post(OC.filePath('news', 'ajax', 'loadfeed.php'), data, function(jsonData) { // prevent loading in selected feeds that are not active any more when // the post finishes later if(self._lastActiveFeedType === type && self._lastActiveFeedId === id){ -- cgit v1.2.3