0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Fixed inconsistent theme settings state after toggling customThemeSettings labs flag

no issue

If Ghost was booted or a theme activated with the `customThemeSettings` flag disabled but with a theme that has custom settings, enabling the flag later on wouldn't show the settings in Admin or make the settings available in the front-end. Similarly, disabling `customThemeSettings` when Ghost had been booted/or theme activated with it enabled meant that settings were still available on the front-end.

- added an event listener for `settings.labs.edited` that fully re-activates a theme so that it's passed through gscan again and the custom theme settings passed back are included/excluded based on the flag value and any required settings sync with the database is performed
This commit is contained in:
Kevin Ansfield 2021-10-04 10:58:20 +01:00
parent d07fc708ab
commit 25b0657784

View file

@ -6,6 +6,12 @@ const installer = require('./installer');
const settingsCache = require('../../../shared/settings-cache');
// Needed for theme re-activation after customThemeSettings flag is toggled
// @TODO: remove when customThemeSettings flag is removed
const labs = require('../../../shared/labs');
const events = require('../../lib/common/events');
let _lastLabsValue;
module.exports = {
/*
* Load the currently active theme
@ -13,6 +19,21 @@ module.exports = {
init: async () => {
const themeName = settingsCache.get('active_theme');
/**
* When customThemeSettings labs flag is toggled we need to re-validate and activate
* the active theme so that it's settings are read and synced
*
* @TODO: remove when customThemeSettings labs flag is removed
*/
_lastLabsValue = labs.isSet('customThemeSettings');
events.on('settings.labs.edited', () => {
if (labs.isSet('customThemeSettings') !== _lastLabsValue) {
_lastLabsValue = labs.isSet('customThemeSettings');
activate.activate(settingsCache.get('active_theme'));
}
});
return activate.loadAndActivate(themeName);
},
/**