mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 07:51:36 +08: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;
|
||||
export function createHelperContext(siteSettings) {
|
||||
_helperContext = {
|
||||
siteSettings
|
||||
};
|
||||
export function createHelperContext(ctx) {
|
||||
_helperContext = ctx;
|
||||
}
|
||||
|
||||
// This can be used by a helper to get the SiteSettings. Note you should not
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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";
|
||||
|
||||
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" }
|
||||
);
|
||||
}
|
||||
return Discourse.__container__
|
||||
.lookup("service:theme-settings")
|
||||
.getSetting(themeId, key);
|
||||
return helperContext().themeSettings.getSetting(themeId, key);
|
||||
});
|
||||
|
|
|
@ -16,7 +16,8 @@ export function autoLoadModules(container, registry) {
|
|||
}
|
||||
});
|
||||
let siteSettings = container.lookup("site-settings:main");
|
||||
createHelperContext(siteSettings);
|
||||
let themeSettings = container.lookup("service:theme-settings");
|
||||
createHelperContext({ siteSettings, themeSettings });
|
||||
registerHelpers(registry);
|
||||
registerRawHelpers(RawHandlebars, Handlebars);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ QUnit.testStart(function(ctx) {
|
|||
Session.resetCurrent();
|
||||
User.resetCurrent();
|
||||
resetSite(settings);
|
||||
createHelperContext(settings);
|
||||
createHelperContext({ siteSettings: settings });
|
||||
|
||||
_DiscourseURL.redirectedTo = null;
|
||||
_DiscourseURL.redirectTo = function(url) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user