FIX: Refresh logic in discovery topic lists (#15489)

Before 6e0e6014, the flow looked something like:

1. `discovery/topics` controller (which extends `discovery` controller) `afterRefresh()` calls `.send("loadingComplete")`
2. Bubbles to [`discovery` route](554ff07786/app/assets/javascripts/discourse/app/routes/discovery.js (L58))
3. Discovery route calls `controllerFor('discovery').loadingComplete()`. `loading` is set false, and the spinner disappears

Now that `discovery/topics` defines `loadingComplete` as an action, the `discovery/topics` controller runs its own `loadingComplete` handler logic in step 1, and the action does not bubble any further.

This commit adds action overrides in `discovery/topics`, so that the new actions only apply to the main `discovery` controller. The need for this does suggest some more radical refactoring is required, but these are very critical routes, and we are very close to a major release.
This commit is contained in:
David Taylor 2022-01-07 17:22:49 +00:00 committed by GitHub
parent 554ff07786
commit f94c01b233
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import { endWith } from "discourse/lib/computed";
import { routeAction } from "discourse/helpers/route-action";
import { inject as service } from "@ember/service";
import { userPath } from "discourse/lib/url";
import { action } from "@ember/object";
const controllerOpts = {
discovery: controller(),
@ -32,6 +33,18 @@ const controllerOpts = {
selected: null,
// Remove these actions which are defined in `DiscoveryController`
// We want them to bubble in DiscoveryTopicsController
@action
loadingBegan() {
return true;
},
@action
loadingComplete() {
return true;
},
@discourseComputed("model.filter", "model.topics.length")
showDismissRead(filter, topicsLength) {
return this._isFilterPage(filter, "unread") && topicsLength > 0;