mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Don't overwrite computed property for loading spinner fix
This fixes an issue CvX found on PR #14666 where a previous fix overwrote a computed property. The better fix (as is often the case with Ember) is to remove an observer and call methods when things change ourselves.
This commit is contained in:
parent
9ebfcbb867
commit
2c045c6368
@ -2,7 +2,6 @@ import Controller, { inject as controller } from "@ember/controller";
|
|||||||
import { alias, equal, not } from "@ember/object/computed";
|
import { alias, equal, not } from "@ember/object/computed";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
@ -14,7 +13,6 @@ export default Controller.extend({
|
|||||||
"router.currentRouteName",
|
"router.currentRouteName",
|
||||||
"discovery.categories"
|
"discovery.categories"
|
||||||
),
|
),
|
||||||
|
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
category: alias("navigationCategory.category"),
|
category: alias("navigationCategory.category"),
|
||||||
@ -22,8 +20,13 @@ export default Controller.extend({
|
|||||||
|
|
||||||
loadedAllItems: not("discoveryTopics.model.canLoadMore"),
|
loadedAllItems: not("discoveryTopics.model.canLoadMore"),
|
||||||
|
|
||||||
@observes("loadedAllItems")
|
loadingBegan() {
|
||||||
_showFooter() {
|
this.set("loading", true);
|
||||||
|
this.set("application.showFooter", false);
|
||||||
|
},
|
||||||
|
|
||||||
|
loadingComplete() {
|
||||||
|
this.set("loading", false);
|
||||||
this.set("application.showFooter", this.loadedAllItems);
|
this.set("application.showFooter", this.loadedAllItems);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -66,15 +66,14 @@ const controllerOpts = {
|
|||||||
this.send("resetParams", options.skipResettingParams);
|
this.send("resetParams", options.skipResettingParams);
|
||||||
|
|
||||||
// Don't refresh if we're still loading
|
// Don't refresh if we're still loading
|
||||||
if (this.get("discovery.loading")) {
|
if (this.discovery.loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we `send('loading')` here, due to returning true it bubbles up to the
|
// If we `send('loading')` here, due to returning true it bubbles up to the
|
||||||
// router and ember throws an error due to missing `handlerInfos`.
|
// router and ember throws an error due to missing `handlerInfos`.
|
||||||
// Lesson learned: Don't call `loading` yourself.
|
// Lesson learned: Don't call `loading` yourself.
|
||||||
this.set("discovery.loading", true);
|
this.discovery.loadingBegan();
|
||||||
this.set("model.canLoadMore", true);
|
|
||||||
|
|
||||||
this.topicTrackingState.resetTracking();
|
this.topicTrackingState.resetTracking();
|
||||||
|
|
||||||
|
@ -46,25 +46,24 @@ export default DiscourseRoute.extend(OpenComposer, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
loading() {
|
loading() {
|
||||||
this.controllerFor("discovery").set("loading", true);
|
this.controllerFor("discovery").loadingBegan();
|
||||||
|
|
||||||
|
// We don't want loading to bubble
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
loadingComplete() {
|
loadingComplete() {
|
||||||
this.controllerFor("discovery").set("loading", false);
|
this.controllerFor("discovery").loadingComplete();
|
||||||
if (!this.session.get("topicListScrollPosition")) {
|
if (!this.session.get("topicListScrollPosition")) {
|
||||||
scrollTop();
|
scrollTop();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
didTransition() {
|
didTransition() {
|
||||||
this.controllerFor("discovery")._showFooter();
|
|
||||||
this.send("loadingComplete");
|
this.send("loadingComplete");
|
||||||
|
|
||||||
const model = this.controllerFor("discovery/topics").get("model");
|
const model = this.controllerFor("discovery/topics").get("model");
|
||||||
setTopicList(model);
|
setTopicList(model);
|
||||||
return false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// clear a pinned topic
|
// clear a pinned topic
|
||||||
|
Loading…
Reference in New Issue
Block a user