Skip to content

Commit

Permalink
fix: fix strange test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
pangbo13 committed Nov 21, 2024
1 parent b329ffd commit 042613d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions assets/javascripts/discourse/initializers/retort-init.js.es6
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import { getOwnerWithFallback } from "discourse-common/lib/get-owner";

function initializePlugin(api) {
const { retort_enabled } = api._lookupContainer("site-settings:main");
const Retort = api.container.lookup("service:retort");

if (!retort_enabled) {
return;
}
const currentUser = api.getCurrentUser();

api.modifyClass("controller:preferences/notifications", {
Expand All @@ -31,6 +26,7 @@ function initializePlugin(api) {
});

api.addPostClassesCallback((attrs) => {
const Retort = getOwnerWithFallback(api).lookup("service:retort");
if (!Retort.disableShowForTopic(attrs.topic)) {
return ["retort"];
}
Expand Down Expand Up @@ -77,14 +73,18 @@ function initializePlugin(api) {
});

api.attachWidgetAction("post-menu", "clickRetort", function () {
const Retort = getOwnerWithFallback(api).lookup("service:retort");
const post = this.findAncestorModel();
Retort.openPicker(post);
});
}

export default {
name: "retort",
initialize: function () {
withPluginApi("0.8.6", (api) => initializePlugin(api));
initialize: function (container) {
if (!container.lookup("service:site-settings").retort_enabled) {
return;
}
withPluginApi("1.3", (api) => initializePlugin(api));
},
};

0 comments on commit 042613d

Please sign in to comment.