From 7327dbc7cc6ecd3de4d77256bc44b82576240097 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 29 Oct 2014 17:17:32 +1100 Subject: [PATCH] PERF: don't render the category list if we are not showing it. --- .../discourse/components/category-drop.js.es6 | 13 +++++++++++-- .../templates/components/category-drop.hbs | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/category-drop.js.es6 b/app/assets/javascripts/discourse/components/category-drop.js.es6 index 3b4553eb1cc..b05b9dcd77f 100644 --- a/app/assets/javascripts/discourse/components/category-drop.js.es6 +++ b/app/assets/javascripts/discourse/components/category-drop.js.es6 @@ -57,6 +57,16 @@ export default Ember.Component.extend({ actions: { expand: function() { + var self = this; + + if(!this.get('renderCategories')){ + this.set('renderCategories',true); + Em.run.next(function(){ + self.send('expand'); + }); + return; + } + if (this.get('expanded')) { this.close(); return; @@ -65,8 +75,7 @@ export default Ember.Component.extend({ if (this.get('categories')) { this.set('expanded', true); } - var self = this, - $dropdown = this.$()[0]; + var $dropdown = this.$()[0]; this.$('a[data-drop-close]').on('click.category-drop', function() { self.close(); diff --git a/app/assets/javascripts/discourse/templates/components/category-drop.hbs b/app/assets/javascripts/discourse/templates/components/category-drop.hbs index 1123fa6befb..835e9ceb7e6 100644 --- a/app/assets/javascripts/discourse/templates/components/category-drop.hbs +++ b/app/assets/javascripts/discourse/templates/components/category-drop.hbs @@ -20,6 +20,8 @@ {{#if subCategory}}
{{i18n categories.no_subcategory}}
{{/if}} + {{#if renderCategories}} {{#each categories}}
{{category-link this allowUncategorized=true}}
{{/each}} + {{/if}} {{/if}}