From 363e1010c40432444a1d46817dc882a22b4a065e Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 Jul 2013 21:23:01 +1000 Subject: [PATCH] never double load the stream. --- app/assets/javascripts/discourse/models/user_stream.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/models/user_stream.js b/app/assets/javascripts/discourse/models/user_stream.js index 2957fe67acc..a10193fff11 100644 --- a/app/assets/javascripts/discourse/models/user_stream.js +++ b/app/assets/javascripts/discourse/models/user_stream.js @@ -17,6 +17,10 @@ Discourse.UserStream = Discourse.Model.extend({ }.observes('filter'), findItems: function() { + var me = this; + if(this.get("loading")) { return; } + this.set("loading",true); + var url = Discourse.getURL("/user_actions.json?offset=") + this.get('itemsLoaded') + "&username=" + (this.get('user.username_lower')); if (this.get('filter')) { url += "&filter=" + (this.get('filter')); @@ -24,6 +28,7 @@ Discourse.UserStream = Discourse.Model.extend({ var stream = this; return Discourse.ajax(url, {cache: 'false'}).then( function(result) { + me.set("loading",false); if (result && result.user_actions) { var copy = Em.A(); _.each(result.user_actions,function(action) { @@ -33,7 +38,7 @@ Discourse.UserStream = Discourse.Model.extend({ stream.get('content').pushObjects(copy); stream.set('itemsLoaded', stream.get('itemsLoaded') + result.user_actions.length); } - }); + }, function(){ me.set("loading", false); }); } });