DEV: Don't set appEvents on app, group injections (#14929)

DEV: Don’t set appEvents on app, group injections (#14929)

diff --git a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
index 10fb070..2149b8f 100644
--- a/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
+++ b/app/assets/javascripts/discourse/app/pre-initializers/inject-discourse-objects.js
@@ -24,9 +24,6 @@ export function registerObjects(container, app) {
   app.register("store:main", Store);
   app.register("service:store", Store);
 
-  // backwards compatibility: remove when plugins have updated
-  app.appEvents = container.lookup("service:app-events");
-
   // TODO: This should be included properly
   app.register("message-bus:main", MessageBus, { instantiate: false });
 
@@ -43,19 +40,10 @@ export default {
 
     let siteSettings = container.lookup("site-settings:main");
 
-    ALL_TARGETS.forEach((t) =>
-      app.inject(t, "appEvents", "service:app-events")
-    );
-
     const currentUser = User.current();
     app.register("current-user:main", currentUser, { instantiate: false });
     app.currentUser = currentUser;
 
-    ALL_TARGETS.forEach((t) => {
-      app.inject(t, "topicTrackingState", "topic-tracking-state:main");
-      app.inject(t, "pmTopicTrackingState", "pm-topic-tracking-state:main");
-    });
-
     const topicTrackingState = TopicTrackingState.create({
       messageBus: MessageBus,
       siteSettings,
@@ -97,24 +85,21 @@ export default {
     app.register("key-value-store:main", keyValueStore, { instantiate: false });
     app.register("search-service:main", SearchService);
 
-    ALL_TARGETS.forEach((t) => app.inject(t, "store", "service:store"));
-
-    ALL_TARGETS.concat("service").forEach((t) =>
-      app.inject(t, "messageBus", "message-bus:main")
-    );
-
-    ALL_TARGETS.concat("service").forEach((t) =>
-      app.inject(t, "siteSettings", "site-settings:main")
-    );
-
-    ALL_TARGETS.forEach((t) => app.inject(t, "site", "site:main"));
-
-    ALL_TARGETS.forEach((t) =>
-      app.inject(t, "searchService", "search-service:main")
-    );
+    ALL_TARGETS.forEach((t) => {
+      app.inject(t, "appEvents", "service:app-events");
+      app.inject(t, "topicTrackingState", "topic-tracking-state:main");
+      app.inject(t, "pmTopicTrackingState", "pm-topic-tracking-state:main");
+      app.inject(t, "store", "service:store");
+      app.inject(t, "site", "site:main");
+      app.inject(t, "searchService", "search-service:main");
+      app.inject(t, "keyValueStore", "key-value-store:main");
+    });
 
-    ALL_TARGETS.forEach((t) => app.inject(t, "session", "session:main"));
-    app.inject("service", "session", "session:main");
+    ALL_TARGETS.concat("service").forEach((t) => {
+      app.inject(t, "session", "session:main");
+      app.inject(t, "messageBus", "message-bus:main");
+      app.inject(t, "siteSettings", "site-settings:main");
+    });
 
     if (currentUser) {
       ["component", "route", "controller", "service"].forEach((t) => {
@@ -122,10 +107,6 @@ export default {
       });
     }
 
-    ALL_TARGETS.forEach((t) =>
-      app.inject(t, "keyValueStore", "key-value-store:main")
-    );
-
     startTracking(topicTrackingState);
   },
 };

GitHub sha: 25251d4d004ceacdf7c6066e6b114789d08e41ad

This commit appears in #14929 which was approved by martin. It was merged by CvX.