mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: Add themeSettings
to the helperContext
to avoid a global
This commit is contained in:
parent
8ac85f54fb
commit
41fd7a8b72
@ -46,10 +46,8 @@ export function registerHelpers(registry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _helperContext;
|
let _helperContext;
|
||||||
export function createHelperContext(siteSettings) {
|
export function createHelperContext(ctx) {
|
||||||
_helperContext = {
|
_helperContext = ctx;
|
||||||
siteSettings
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can be used by a helper to get the SiteSettings. Note you should not
|
// This can be used by a helper to get the SiteSettings. Note you should not
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { registerUnbound } from "discourse-common/lib/helpers";
|
import { helperContext, registerUnbound } from "discourse-common/lib/helpers";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
registerUnbound("theme-i18n", (themeId, key, params) => {
|
registerUnbound("theme-i18n", (themeId, key, params) => {
|
||||||
@ -18,7 +18,5 @@ registerUnbound("theme-setting", (themeId, key, hash) => {
|
|||||||
{ since: "v2.2.0.beta8", dropFrom: "v2.3.0" }
|
{ since: "v2.2.0.beta8", dropFrom: "v2.3.0" }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Discourse.__container__
|
return helperContext().themeSettings.getSetting(themeId, key);
|
||||||
.lookup("service:theme-settings")
|
|
||||||
.getSetting(themeId, key);
|
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,8 @@ export function autoLoadModules(container, registry) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
let siteSettings = container.lookup("site-settings:main");
|
let siteSettings = container.lookup("site-settings:main");
|
||||||
createHelperContext(siteSettings);
|
let themeSettings = container.lookup("service:theme-settings");
|
||||||
|
createHelperContext({ siteSettings, themeSettings });
|
||||||
registerHelpers(registry);
|
registerHelpers(registry);
|
||||||
registerRawHelpers(RawHandlebars, Handlebars);
|
registerRawHelpers(RawHandlebars, Handlebars);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ QUnit.testStart(function(ctx) {
|
|||||||
Session.resetCurrent();
|
Session.resetCurrent();
|
||||||
User.resetCurrent();
|
User.resetCurrent();
|
||||||
resetSite(settings);
|
resetSite(settings);
|
||||||
createHelperContext(settings);
|
createHelperContext({ siteSettings: settings });
|
||||||
|
|
||||||
_DiscourseURL.redirectedTo = null;
|
_DiscourseURL.redirectedTo = null;
|
||||||
_DiscourseURL.redirectTo = function(url) {
|
_DiscourseURL.redirectTo = function(url) {
|
||||||
|
Loading…
Reference in New Issue
Block a user