FIX: Correct getOwner import (#260)

As it's currently implemented, the fallback is essential here. `this` in a static method is `undefined`, and therefore cannot have an owner.

Unfortunately this plugin outlet does not seem to be tested in the plugin's own test suite. Core's test suite picked up this issue.

Followup to 3a0b46da7aa48e27e51c74e90b42c2083d89b4d5
This commit is contained in:
David Taylor 2023-10-17 23:37:07 +01:00 committed by GitHub
parent 3a0b46da7a
commit 56d936be63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import I18n from "I18n"; import I18n from "I18n";
import { getOwner } from "@ember/application"; import { getOwnerWithFallback } from "discourse-common/lib/get-owner";
import Component from "@glimmer/component"; import Component from "@glimmer/component";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
@ -17,7 +17,7 @@ const UX_VALUES = {
export default class SolvedStatusFilter extends Component { export default class SolvedStatusFilter extends Component {
static shouldRender(args, helper) { static shouldRender(args, helper) {
const router = getOwner(this).lookup("service:router"); const router = getOwnerWithFallback(this).lookup("service:router");
if ( if (
!helper.siteSettings.show_filter_by_solved_status || !helper.siteSettings.show_filter_by_solved_status ||