2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

FIX: In test mode, initializers were modifying classes over and over

This adds a new property, `pluginId` which you can pass to `modifyClass`
which prevent the class from being modified over and over again.

This also includes a fix for polls which was leaking state between tests
which this new functionality exposed.
This commit is contained in:
Robin Ward 2021-09-01 14:29:07 -04:00
parent fa66d1fa82
commit 09764291b1
6 changed files with 66 additions and 19 deletions

View file

@ -1,12 +1,15 @@
import { ajax } from "discourse/lib/ajax";
import { withPluginApi } from "discourse/lib/plugin-api";
const PLUGIN_ID = "new-user-narrative";
function initialize(api) {
const messageBus = api.container.lookup("message-bus:main");
const currentUser = api.getCurrentUser();
const appEvents = api.container.lookup("service:app-events");
api.modifyClass("component:site-header", {
pluginId: PLUGIN_ID,
didInsertElement() {
this._super(...arguments);
this.dispatch("header:search-context-trigger", "header");
@ -14,6 +17,8 @@ function initialize(api) {
});
api.modifyClass("controller:topic", {
pluginId: PLUGIN_ID,
_togglePostBookmark(post) {
// if we are talking to discobot then any bookmarks should just
// be created without reminder options, to streamline the new user