DEV: Use service: lookups instead of :main (#25402)

where applicable
This commit is contained in:
Jarek Radosz 2024-01-24 15:59:44 +01:00 committed by GitHub
parent 57c4b6bd50
commit fd3c3fa565
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 9 additions and 11 deletions

View File

@ -160,12 +160,12 @@ const DiscourseURL = EmberObject.extend({
replaceState(path) {
if (path.startsWith("#")) {
path = this.router.currentURL.replace(/#.*$/, "") + path;
path = this.routerService.currentURL.replace(/#.*$/, "") + path;
}
path = withoutPrefix(path);
if (this.router.currentURL !== path) {
if (this.routerService.currentURL !== path) {
// Always use replaceState in the next runloop to prevent weird routes changing
// while URLs are loading. For example, while a topic loads it sets `currentPost`
// which triggers a replaceState even though the topic hasn't fully loaded yet!
@ -228,7 +228,7 @@ const DiscourseURL = EmberObject.extend({
return this.replaceState(path);
}
const oldPath = this.router.currentURL;
const oldPath = this.routerService.currentURL;
path = path.replace(/(https?\:)?\/\/[^\/]+/, "");
@ -415,8 +415,6 @@ const DiscourseURL = EmberObject.extend({
handleURL(path, opts) {
opts = opts || {};
const router = this.router;
if (opts.replaceURL) {
this.replaceState(path);
}
@ -429,7 +427,7 @@ const DiscourseURL = EmberObject.extend({
elementId = split[1];
}
const transition = router.transitionTo(path);
const transition = this.routerService.transitionTo(path);
transition._discourse_intercepted = true;
transition._discourse_anchor = elementId;

View File

@ -4,7 +4,7 @@ import { iconHTML } from "discourse-common/lib/icon-library";
import I18n from "discourse-i18n";
function initializePlugin(api) {
const siteSettings = api.container.lookup("site-settings:main");
const siteSettings = api.container.lookup("service:site-settings");
if (siteSettings.checklist_enabled) {
api.decorateCookedElement(checklistSyntax);

View File

@ -12,7 +12,7 @@ function initLazyEmbed(api) {
const lazyContainers = cooked.querySelectorAll(".lazy-video-container");
lazyContainers.forEach((container) => {
const siteSettings = api.container.lookup("site-settings:main");
const siteSettings = api.container.lookup("service:site-settings");
const videoAttributes = getVideoAttributes(container);
if (siteSettings[`lazy_${videoAttributes.providerName}_enabled`]) {

View File

@ -100,7 +100,7 @@ export default {
name: "inline-footnotes",
initialize(container) {
if (!container.lookup("site-settings:main").display_footnotes_inline) {
if (!container.lookup("service:site-settings").display_footnotes_inline) {
return;
}

View File

@ -134,7 +134,7 @@ function initializePolls(api) {
});
api.cleanupStream(cleanUpPolls);
const siteSettings = api.container.lookup("site-settings:main");
const siteSettings = api.container.lookup("service:site-settings");
if (siteSettings.poll_enabled) {
api.addSearchSuggestion("in:polls");
}

View File

@ -49,7 +49,7 @@ export default {
name: "spoiler-alert",
initialize(container) {
const siteSettings = container.lookup("site-settings:main");
const siteSettings = container.lookup("service:site-settings");
if (siteSettings.spoiler_enabled) {
withPluginApi("1.15.0", initializeSpoiler);