Added missing async/await calls

- 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
This commit is contained in:
Hannah Wolfe 2021-11-23 17:02:09 +00:00
parent b98fd62a3d
commit 6247aa4d8b
No known key found for this signature in database
GPG Key ID: AB586C3B5AE5C037
2 changed files with 8 additions and 8 deletions

View File

@ -50,7 +50,7 @@ class Bridge {
return themeEngine.getActive();
}
activateTheme(loadedTheme, checkedTheme) {
async activateTheme(loadedTheme, checkedTheme) {
let settings = {
locale: settingsCache.get('lang')
};
@ -68,12 +68,12 @@ class Bridge {
if (previousGhostAPI !== undefined && (previousGhostAPI !== currentGhostAPI)) {
events.emit('services.themes.api.changed');
this.reloadFrontend();
await this.reloadFrontend();
}
const cardAssetConfig = this.getCardAssetConfig();
debug('reload card assets config', cardAssetConfig);
cardAssetService.load(cardAssetConfig);
await cardAssetService.load(cardAssetConfig);
} catch (err) {
logging.error(new errors.InternalServerError({
message: tpl(messages.activateFailed, {theme: loadedTheme.name}),
@ -98,12 +98,12 @@ class Bridge {
}
}
reloadFrontend() {
async reloadFrontend() {
const apiVersion = this.getFrontendApiVersion();
debug('reload frontend', apiVersion);
const siteApp = require('./frontend/web/site');
siteApp.reload({apiVersion});
await siteApp.reload({apiVersion});
}
}

View File

@ -14,7 +14,7 @@ module.exports = {
if (labs.isSet('customThemeSettings')) {
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
}
bridge.activateTheme(theme, checkedTheme);
await bridge.activateTheme(theme, checkedTheme);
},
activateFromAPI: async (themeName, theme, checkedTheme) => {
debug('Activating theme (method B on API "activate")', themeName);
@ -22,7 +22,7 @@ module.exports = {
if (labs.isSet('customThemeSettings')) {
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
}
bridge.activateTheme(theme, checkedTheme);
await bridge.activateTheme(theme, checkedTheme);
},
activateFromAPIOverride: async (themeName, theme, checkedTheme) => {
debug('Activating theme (method C on API "override")', themeName);
@ -30,6 +30,6 @@ module.exports = {
if (labs.isSet('customThemeSettings')) {
await customThemeSettings.api.activateTheme(themeName, checkedTheme);
}
bridge.activateTheme(theme, checkedTheme);
await bridge.activateTheme(theme, checkedTheme);
}
};