From 27d43ad6c0a62e7071a01206284c71ce51c63bd0 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 22 Dec 2014 13:18:19 +1100 Subject: [PATCH] PERF: hold back rendering of suggested topics 1 run loop. --- .../javascripts/discourse/controllers/topic.js.es6 | 14 ++++++++++++++ .../javascripts/discourse/templates/topic.hbs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index a611d8033bc..92e06d8f83a 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -41,6 +41,20 @@ export default ObjectController.extend(Discourse.SelectedPostsCount, { }.observes('controllers.search.term', 'controllers.header.visibleDropdown'), + postStreamLoadedAllPostsChanged: function(){ + // hold back rendering 1 run loop for every transition. + var self = this; + var loaded = this.get('postStream.loadedAllPosts'); + this.set('loadedAllPosts', false); + + if(loaded){ + Em.run.next(function(){ + self.set('loadedAllPosts',true); + }); + } + + }.observes('postStream', 'postStream.loadedAllPosts'), + show_deleted: function(key, value) { var postStream = this.get('postStream'); if (!postStream) { return; } diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index 0a63267eadf..54f6fad5cac 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -90,7 +90,7 @@
{{#loading-spinner condition=postStream.loadingFilter}} - {{#if postStream.loadedAllPosts}} + {{#if loadedAllPosts}} {{view 'topic-closing' topic=model}} {{view 'topic-footer-buttons' topic=model}}