mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
6247aa4d8b
- throughout the theme activation flow there are several missing awaits and necessary async keywords - we should be waiting on these processes, not letting them complete indeterministically
36 lines
1.7 KiB
JavaScript
36 lines
1.7 KiB
JavaScript
const debug = require('@tryghost/debug')('themes');
|
|
const bridge = require('../../../bridge');
|
|
const labs = require('../../../shared/labs');
|
|
const customThemeSettings = require('../custom-theme-settings');
|
|
|
|
/**
|
|
* These helper methods mean that the bridge is only required in one place
|
|
* And also adds a little debug statement, which is very handy when debugging theme logic
|
|
*/
|
|
module.exports = {
|
|
activateFromBoot: async (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method A on boot)', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
|
|
}
|
|
await bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPI: async (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method B on API "activate")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
|
|
}
|
|
await bridge.activateTheme(theme, checkedTheme);
|
|
},
|
|
activateFromAPIOverride: async (themeName, theme, checkedTheme) => {
|
|
debug('Activating theme (method C on API "override")', themeName);
|
|
// TODO: probably a better place for this to happen - after successful activation / when reloading site?
|
|
if (labs.isSet('customThemeSettings')) {
|
|
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
|
|
}
|
|
await bridge.activateTheme(theme, checkedTheme);
|
|
}
|
|
};
|