diff --git a/app/assets/javascripts/discourse-common/addon/resolver.js b/app/assets/javascripts/discourse-common/addon/resolver.js index e2683c37d07..5ff207f3543 100644 --- a/app/assets/javascripts/discourse-common/addon/resolver.js +++ b/app/assets/javascripts/discourse-common/addon/resolver.js @@ -78,6 +78,11 @@ const DEPRECATED_MODULES = new Map( since: "2.9.0.beta7", dropFrom: "3.0.0", }, + "site:main": { + newName: "service:site", + since: "2.9.0.beta7", + dropFrom: "3.0.0", + }, }) ); diff --git a/app/assets/javascripts/discourse/app/components/glimmer.js b/app/assets/javascripts/discourse/app/components/glimmer.js index 1910705410f..9fce9cb0ef0 100644 --- a/app/assets/javascripts/discourse/app/components/glimmer.js +++ b/app/assets/javascripts/discourse/app/components/glimmer.js @@ -21,16 +21,11 @@ export default class DiscourseGlimmerComponent extends GlimmerComponent { @service messageBus; @service currentUser; @service session; + @service site; @cached get topicTrackingState() { const applicationInstance = getOwner(this); return applicationInstance.lookup("topic-tracking-state:main"); } - - @cached - get site() { - const applicationInstance = getOwner(this); - return applicationInstance.lookup("site:main"); - } } diff --git a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js index c782483e5c9..9959c6357f9 100644 --- a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js +++ b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js @@ -22,7 +22,7 @@ export function autoLoadModules(container, registry) { keyValueStore: container.lookup("service:key-value-store"), capabilities: container.lookup("capabilities:main"), currentUser: container.lookup("service:current-user"), - site: container.lookup("site:main"), + site: container.lookup("service:site"), session: container.lookup("service:session"), topicTrackingState: container.lookup("topic-tracking-state:main"), registry, diff --git a/app/assets/javascripts/discourse/app/initializers/banner.js b/app/assets/javascripts/discourse/app/initializers/banner.js index 2f9d8c70ad9..194cb8148f8 100644 --- a/app/assets/javascripts/discourse/app/initializers/banner.js +++ b/app/assets/javascripts/discourse/app/initializers/banner.js @@ -7,7 +7,7 @@ export default { initialize(container) { const banner = EmberObject.create(PreloadStore.get("banner") || {}), - site = container.lookup("site:main"); + site = container.lookup("service:site"); site.set("banner", banner); diff --git a/app/assets/javascripts/discourse/app/initializers/mobile.js b/app/assets/javascripts/discourse/app/initializers/mobile.js index 7c992005cb1..029650305dc 100644 --- a/app/assets/javascripts/discourse/app/initializers/mobile.js +++ b/app/assets/javascripts/discourse/app/initializers/mobile.js @@ -9,7 +9,7 @@ export default { initialize(container) { Mobile.init(); - const site = container.lookup("site:main"); + const site = container.lookup("service:site"); site.set("mobileView", Mobile.mobileView); site.set("desktopView", !Mobile.mobileView); diff --git a/app/assets/javascripts/discourse/app/initializers/post-decorations.js b/app/assets/javascripts/discourse/app/initializers/post-decorations.js index dc18583805c..735ee492419 100644 --- a/app/assets/javascripts/discourse/app/initializers/post-decorations.js +++ b/app/assets/javascripts/discourse/app/initializers/post-decorations.js @@ -16,7 +16,7 @@ export default { withPluginApi("0.1", (api) => { const siteSettings = container.lookup("service:site-settings"); const session = container.lookup("service:session"); - const site = container.lookup("site:main"); + const site = container.lookup("service:site"); api.decorateCookedElement( (elem) => { return highlightSyntax(elem, siteSettings, session); diff --git a/app/assets/javascripts/discourse/app/initializers/read-only.js b/app/assets/javascripts/discourse/app/initializers/read-only.js index a4e18215d82..24687a7109b 100644 --- a/app/assets/javascripts/discourse/app/initializers/read-only.js +++ b/app/assets/javascripts/discourse/app/initializers/read-only.js @@ -9,7 +9,7 @@ export default { return; } - const site = container.lookup("site:main"); + const site = container.lookup("service:site"); messageBus.subscribe("/site/read-only", function (enabled) { site.set("isReadOnly", enabled); }); diff --git a/app/assets/javascripts/discourse/app/initializers/subscribe-user-notifications.js b/app/assets/javascripts/discourse/app/initializers/subscribe-user-notifications.js index be4d54ed2af..90ed40130b7 100644 --- a/app/assets/javascripts/discourse/app/initializers/subscribe-user-notifications.js +++ b/app/assets/javascripts/discourse/app/initializers/subscribe-user-notifications.js @@ -132,7 +132,7 @@ export default { appEvents.trigger("user-status:changed", data); }); - const site = container.lookup("site:main"); + const site = container.lookup("service:site"); const router = container.lookup("router:main"); bus.subscribe("/categories", (data) => { diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js index 7eb485b579e..9c4bd3ccf38 100644 --- a/app/assets/javascripts/discourse/app/lib/plugin-api.js +++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js @@ -400,7 +400,7 @@ class PluginApi { * ``` **/ addPosterIcons(cb) { - const site = this._lookupContainer("site:main"); + const site = this._lookupContainer("service:site"); const loc = site && site.mobileView ? "before" : "after"; decorateWidget(`poster-name:${loc}`, (dec) => { 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 3ed9412c460..aa6fa57e68e 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 @@ -51,7 +51,7 @@ export default { }); const site = Site.current(); - app.register("site:main", site, { instantiate: false }); + app.register("service:site", site, { instantiate: false }); const session = Session.current(); app.register("service:session", session, { instantiate: false }); @@ -62,7 +62,7 @@ export default { app.inject(t, "appEvents", "service:app-events"); app.inject(t, "pmTopicTrackingState", "service:pm-topic-tracking-state"); app.inject(t, "store", "service:store"); - app.inject(t, "site", "site:main"); + app.inject(t, "site", "service:site"); app.inject(t, "searchService", "service:search"); app.inject(t, "session", "service:session"); app.inject(t, "messageBus", "service:message-bus"); diff --git a/app/assets/javascripts/discourse/app/widgets/widget.js b/app/assets/javascripts/discourse/app/widgets/widget.js index 13bc3f25333..0985f0283fd 100644 --- a/app/assets/javascripts/discourse/app/widgets/widget.js +++ b/app/assets/javascripts/discourse/app/widgets/widget.js @@ -140,7 +140,7 @@ export default class Widget { register.deprecateContainer(this); this.key = this.buildKey ? this.buildKey(attrs) : null; - this.site = register.lookup("site:main"); + this.site = register.lookup("service:site"); this.siteSettings = register.lookup("service:site-settings"); this.currentUser = register.lookup("service:current-user"); this.capabilities = register.lookup("capabilities:main"); diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-stream-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-stream-test.js index ad494ecedff..81f9c543079 100644 --- a/app/assets/javascripts/discourse/tests/integration/components/widgets/post-stream-test.js +++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/post-stream-test.js @@ -8,7 +8,7 @@ import Topic from "discourse/models/topic"; function postStreamTest(name, attrs) { test(name, async function (assert) { - const site = this.container.lookup("site:main"); + const site = this.container.lookup("service:site"); let posts = attrs.posts.call(this); posts.forEach((p) => p.set("site", site)); this.set("posts", posts); @@ -26,7 +26,7 @@ module("Integration | Component | Widget | post-stream", function (hooks) { postStreamTest("basics", { posts() { - const site = this.container.lookup("site:main"); + const site = this.container.lookup("service:site"); const topic = Topic.create(); topic.set("details.created_by", { id: 123 }); return [ diff --git a/app/assets/javascripts/discourse/tests/setup-tests.js b/app/assets/javascripts/discourse/tests/setup-tests.js index 0ed5afed8d4..a4a539d2c89 100644 --- a/app/assets/javascripts/discourse/tests/setup-tests.js +++ b/app/assets/javascripts/discourse/tests/setup-tests.js @@ -282,7 +282,7 @@ export default function setupTests(config) { }, capabilities: {}, get site() { - return app.__container__.lookup("site:main") || Site.current(); + return app.__container__.lookup("service:site") || Site.current(); }, registry: app.__registry__, });