Removed passing of error to active theme

refs:  076ad99593

- as of 076ad99593 we no longer use the error property of the active theme anywhere
- cleaning up and removing this usage reduces the code pathways and makes the init fn a bit clearer
This commit is contained in:
Hannah Wolfe 2021-07-07 13:09:00 +01:00
parent 9987bdbe17
commit 362140b31e
No known key found for this signature in database
GPG Key ID: 9F8C7532D0A6BA55
2 changed files with 22 additions and 28 deletions

View File

@ -26,16 +26,16 @@ let currentActiveTheme;
class ActiveTheme {
/**
* @TODO this API needs to be simpler, but for now should work!
* @param {object} settings
* @param {string} settings.locale - the active locale for i18n
* @param {object} loadedTheme - the loaded theme object from the theme list
* @param {object} checkedTheme - the result of gscan.format for the theme we're activating
* @param {object} error - bootstrap validates the active theme, we would like to remember this error
*/
constructor(settings, loadedTheme, checkedTheme, error) {
constructor(settings, loadedTheme, checkedTheme) {
// Assign some data, mark it all as pseudo-private
this._name = loadedTheme.name;
this._path = loadedTheme.path;
this._mounted = false;
this._error = error;
// We get passed in a locale
this._locale = settings.locale || 'en';
@ -136,13 +136,14 @@ module.exports = {
* At this point we trust that the theme has been validated.
* Any handling for invalid themes should happen before we get here
*
* @TODO this API needs to be simpler, but for now should work!
* @param {object} settings
* @param {string} settings.locale - the active locale for i18n
* @param {object} loadedTheme - the loaded theme object from the theme list
* @param {object} checkedTheme - the result of gscan.format for the theme we're activating
* @return {ActiveTheme}
*/
set(settings, loadedTheme, checkedTheme, error) {
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme, error);
set(settings, loadedTheme, checkedTheme) {
currentActiveTheme = new ActiveTheme(settings, loadedTheme, checkedTheme);
return currentActiveTheme;
}
};

View File

@ -32,36 +32,29 @@ module.exports = {
.check(theme)
.then(function validationSuccess(checkedTheme) {
if (!validate.canActivate(checkedTheme)) {
const checkError = new errors.ThemeValidationError({
logging.error(new errors.ThemeValidationError({
message: tpl(messages.invalidTheme, {theme: activeThemeName}),
errorDetails: Object.assign(
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
errors: checkedTheme.results.error
}
)
});
logging.error(checkError);
bridge.activateTheme(theme, checkedTheme, checkError);
} else {
}));
// CASE: inform that the theme has errors, but not fatal (theme still works)
if (checkedTheme.results.error.length) {
logging.warn(new errors.ThemeValidationError({
errorType: 'ThemeWorksButHasErrors',
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
errorDetails: Object.assign(
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
errors: checkedTheme.results.error
}
)
}));
}
debug('Activating theme (method A on boot)', activeThemeName);
bridge.activateTheme(theme, checkedTheme);
} else if (checkedTheme.results.error.length) {
logging.warn(new errors.ThemeValidationError({
errorType: 'ThemeWorksButHasErrors',
message: tpl(messages.themeHasErrors, {theme: activeThemeName}),
errorDetails: Object.assign(
_.pick(checkedTheme, ['checkedVersion', 'name', 'path', 'version']), {
errors: checkedTheme.results.error
}
)
}));
}
debug('Activating theme (method A on boot)', activeThemeName);
bridge.activateTheme(theme, checkedTheme);
});
})
.catch(function (err) {