FIX: refresh "/categories" on logo click (#6891)

* FIX: refresh discovery categories on logo click

* Fix prettier offence
This commit is contained in:
Penar Musaraj 2019-01-17 23:08:42 -05:00 committed by Guo Xiang Tan
parent 9f52306861
commit 2274d6d7ac
5 changed files with 10 additions and 21 deletions

View File

@ -46,5 +46,10 @@ export default DiscoveryController.extend({
? "categories_only"
: style;
return Ember.String.dasherize(componentName);
},
actions: {
refresh() {
this.send("triggerRefresh");
}
}
});

View File

@ -13,6 +13,6 @@ export default {
willDestroyElement() {
this._super(...arguments);
this.appEvents.off("url:refresh", this, this.refresh);
this.appEvents.off("url:refresh");
}
};

View File

@ -94,24 +94,8 @@ const DiscoveryCategoriesRoute = Discourse.Route.extend(OpenComposer, {
},
actions: {
refresh() {
const controller = this.controllerFor("discovery/categories");
const discController = this.controllerFor("discovery");
// Don't refresh if we're still loading
if (!discController || discController.get("loading")) {
return;
}
// If we `send('loading')` here, due to returning true it bubbles up to the
// router and ember throws an error due to missing `handlerInfos`.
// Lesson learned: Don't call `loading` yourself.
discController.set("loading", true);
this.model().then(model => {
this.setupController(controller, model);
controller.send("loadingComplete");
});
triggerRefresh() {
this.refresh();
},
createCategory() {

View File

@ -1,4 +1,4 @@
{{#discovery-categories refresh=refresh}}
{{#discovery-categories refresh=(action "refresh")}}
{{component categoryPageStyle
categories=model.categories
latestTopicOnly=latestTopicOnly

View File

@ -1,4 +1,4 @@
{{#discovery-categories refresh=refresh}}
{{#discovery-categories refresh=(action "refresh")}}
{{component categoryPageStyle
categories=model.categories
latestTopicOnly=latestTopicOnly