From 9de06497a9960ce8d7d3709e905824c11fab9c28 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 30 Jan 2015 12:12:30 +1030 Subject: [PATCH] Only load posts once when entering a discussion --- framework/core/ember/app/views/discussion.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/framework/core/ember/app/views/discussion.js b/framework/core/ember/app/views/discussion.js index 0cb73bb4c..548d89317 100644 --- a/framework/core/ember/app/views/discussion.js +++ b/framework/core/ember/app/views/discussion.js @@ -11,6 +11,8 @@ export default Ember.View.extend(Ember.Evented, { sidebarItems: null, + loadingNumber: false, + didInsertElement: function() { // Create and populate an array of items to be rendered in the sidebar. var sidebarItems = TaggedArray.create(); @@ -28,20 +30,27 @@ export default Ember.View.extend(Ember.Evented, { // changes, we want to tell our stream content component to jump down // to it. this.get('controller').on('startWasChanged', this, this.goToNumber); + this.get('streamContent').on('loadedNumber', this, this.loadedNumber); }, willDestroyElement: function() { this.get('controller').off('startWasChanged', this, this.goToNumber); + this.get('streamContent').off('loadedNumber', this, this.loadedNumber); }, goToNumber: function(start) { // We can only proceed if the controller has loaded the discussion // details and the view has been rendered. - if (this.get('controller.loaded') && this.get('streamContent')) { + if (this.get('controller.loaded') && this.get('streamContent') && ! this.get('loadingNumber')) { this.get('streamContent').send('goToNumber', start); + this.set('loadingNumber', true); } }, + loadedNumber: function() { + this.set('loadingNumber', false); + }, + // ------------------------------------------------------------------------ // OBSERVERS // ------------------------------------------------------------------------