FIX: Add an `id` to prevent memory leaks

FIX: Add an id to prevent memory leaks

diff --git a/assets/javascripts/initializers/add-holiday-flair.js.es6 b/assets/javascripts/initializers/add-holiday-flair.js.es6
index 87bb363..30d3180 100644
--- a/assets/javascripts/initializers/add-holiday-flair.js.es6
+++ b/assets/javascripts/initializers/add-holiday-flair.js.es6
@@ -25,7 +25,7 @@ export default {
             .append(iconHTML("calendar-alt"))
             .addClass("on-holiday");
         });
-      });
+      }, { id: 'discourse-calendar' });
 
       api.addPosterIcon(cfs => {
         const onHoliday = customBool(cfs.on_holiday);

GitHub sha: f4ab02e4

1 Like

I wonder … can “api” object auto inject this for plugins by default?

withPluginApi("0.1", "discourse-calender", api =>)

I know it would be a reasonably big change, but then the information about who owns what could be propagated everywhere. I guess there are still edge cases where you decorate cooked multiple times.

Yeah it only really works when there is one decorator, and of course we’d need to change the plugin API to take a name.

This was the easiest and less intrusive solution @jjaffeux and I could come up with.

3 Likes