From ea84c66fe0675976b2005d010c142f6171be3335 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 2 Sep 2021 14:15:04 -0400 Subject: [PATCH] DEV: This constructs a `pluginId` for `modifyClass` when dispatching events It also helpfully adds the `ignoreMissing` option which was causing logging issues on optional modifications before. --- .../javascripts/discourse/app/lib/plugin-api.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js index 35877fa5aa1..64299bcd5a8 100644 --- a/app/assets/javascripts/discourse/app/lib/plugin-api.js +++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js @@ -1387,12 +1387,17 @@ class PluginApi { * is converted to camelCase and used as the method name for you. */ dispatchWidgetAppEvent(mountedComponent, widgetKey, appEvent) { - this.modifyClass(`component:${mountedComponent}`, { - didInsertElement() { - this._super(); - this.dispatch(appEvent, widgetKey); + this.modifyClass( + `component:${mountedComponent}`, + { + pluginId: `#{mountedComponent}/#{widgetKey}/#{appEvent}`, + didInsertElement() { + this._super(); + this.dispatch(appEvent, widgetKey); + }, }, - }); + { ignoreMissing: true } + ); } }