DEV: Ensure core initializers with `.reopen` are only called once

DEV: Ensure core initializers with .reopen are only called once

diff --git a/app/assets/javascripts/discourse/app/initializers/ember-events.js b/app/assets/javascripts/discourse/app/initializers/ember-events.js
index 98c2a24..a359c0b 100644
--- a/app/assets/javascripts/discourse/app/initializers/ember-events.js
+++ b/app/assets/javascripts/discourse/app/initializers/ember-events.js
@@ -1,9 +1,15 @@
+let initializedOnce = false;
+
 export default {
   name: "ember-events",
 
   initialize: function () {
     // By default Ember listens to too many events. This tells it the only events
-    // we're interested in.
+    // we're interested in. (it removes mousemove and touchmove)
+    if (initializedOnce) {
+      return;
+    }
+
     Ember.EventDispatcher.reopen({
       events: {
         touchstart: "touchStart",
@@ -33,5 +39,7 @@ export default {
         dragend: "dragEnd",
       },
     });
+
+    initializedOnce = true;
   },
 };
diff --git a/app/assets/javascripts/discourse/app/initializers/ember-input-component-extension.js b/app/assets/javascripts/discourse/app/initializers/ember-input-component-extension.js
index 902f795..841ff0e 100644
--- a/app/assets/javascripts/discourse/app/initializers/ember-input-component-extension.js
+++ b/app/assets/javascripts/discourse/app/initializers/ember-input-component-extension.js
@@ -1,15 +1,22 @@
 import TextField from "@ember/component/text-field";
 import TextArea from "@ember/component/text-area";
+let initializedOnce = false;
 
 export default {
   name: "ember-input-component-extensions",
 
   initialize() {
+    if (initializedOnce) {
+      return;
+    }
+
     TextField.reopen({
       attributeBindings: ["aria-describedby", "aria-invalid"],
     });
     TextArea.reopen({
       attributeBindings: ["aria-describedby", "aria-invalid"],
     });
+
+    initializedOnce = true;
   },
 };
diff --git a/app/assets/javascripts/discourse/app/initializers/ember-link-component-extension.js b/app/assets/javascripts/discourse/app/initializers/ember-link-component-extension.js
index 807b58e..33accac 100644
--- a/app/assets/javascripts/discourse/app/initializers/ember-link-component-extension.js
+++ b/app/assets/javascripts/discourse/app/initializers/ember-link-component-extension.js
@@ -1,9 +1,17 @@
+let initializedOnce = false;
+
 export default {
   name: "ember-link-component-extensions",
 
   initialize() {
+    if (initializedOnce) {
+      return;
+    }
+
     Ember.LinkComponent.reopen({
       attributeBindings: ["name"],
     });
+
+    initializedOnce = true;
   },
 };
diff --git a/app/assets/javascripts/discourse/app/initializers/logs-notice.js b/app/assets/javascripts/discourse/app/initializers/logs-notice.js
index 08867d1..164f507 100644
--- a/app/assets/javascripts/discourse/app/initializers/logs-notice.js
+++ b/app/assets/javascripts/discourse/app/initializers/logs-notice.js
@@ -1,11 +1,16 @@
 import LogsNotice from "discourse/services/logs-notice";
 import Singleton from "discourse/mixins/singleton";
+let initializedOnce = false;
 
 export default {
   name: "logs-notice",
   after: "message-bus",
 
   initialize: function (container) {
+    if (initializedOnce) {
+      return;
+    }
+
     const siteSettings = container.lookup("site-settings:main");
     const messageBus = container.lookup("message-bus:main");
     const keyValueStore = container.lookup("key-value-store:main");
@@ -20,5 +25,7 @@ export default {
         });
       },
     });
+
+    initializedOnce = true;
   },
 };

GitHub sha: cc18a5439ce58f5e9b53f3968ffe691d66332766

This commit appears in #14745 which was approved by CvX and jjaffeux. It was merged by davidtaylorhq.