summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-09-17 17:25:14 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-09-17 17:25:14 +0200
commitd1583422bd589cdbcfcc88056470ade50fd04ddc (patch)
tree3f5c7dd38ea46d161937fb2583e4e91717c84e60 /js
parent4e7f675462204f9ab131bd9cfbb83af73b4e9a3f (diff)
If you click on a feed and then on a second feed, the first one is still loaded into the main view if the second one finished faster
: fixed
Diffstat (limited to 'js')
-rw-r--r--js/items.js33
1 files changed, 20 insertions, 13 deletions
diff --git a/js/items.js b/js/items.js
index 4eac81e72..dbe8ca811 100644
--- a/js/items.js
+++ b/js/items.js
@@ -89,6 +89,9 @@ var News = News || {};
* @param onSuccessCallback a callback that is executed when the loading succeeded
*/
Items.prototype.load = function(type, id, onSuccessCallback) {
+ this._lastActiveFeedId = id;
+ this._lastActiveFeedType = type;
+
var self = this;
var data = {
id: id,
@@ -100,20 +103,24 @@ var News = News || {};
this._$articleList.children('ul').hide();
$.post(OC.filePath('news', 'ajax', 'loadfeed.php'), data, function(jsonData) {
- if(jsonData.status == 'success'){
- self._$articleList.empty() // FIXME: does this also removed cached items?
- self._itemCache.populate(jsonData.data.feedItems);
-
- var $items = self._itemCache.getFeedHtml(type, id);
- self._$articleList.append($items);
- self._$articleList.scrollTop(0);
- onSuccessCallback();
- } else {
- OC.dialogs.alert(t('news', 'Error while loading the feed'), t('news', 'Error'));
- self._$articleList.children('ul').show();
+ // prevent loading in selected feeds that are not active any more when
+ // the post finishes later
+ if(self._lastActiveFeedType === type && self._lastActiveFeedId === id){
+ if(jsonData.status == 'success'){
+ self._$articleList.empty() // FIXME: does this also removed cached items?
+ self._itemCache.populate(jsonData.data.feedItems);
+
+ var $items = self._itemCache.getFeedHtml(type, id);
+ self._$articleList.append($items);
+ self._$articleList.scrollTop(0);
+ onSuccessCallback();
+ } else {
+ OC.dialogs.alert(t('news', 'Error while loading the feed'), t('news', 'Error'));
+ self._$articleList.children('ul').show();
+ }
+ self._$articleList.removeClass('loading');
+ self._setScrollBottom();
}
- self._$articleList.removeClass('loading');
- self._setScrollBottom();
});
};