diff --git a/core/frontend/services/themes/storage.js b/core/frontend/services/themes/storage.js index d21cac25b3..fadb418fad 100644 --- a/core/frontend/services/themes/storage.js +++ b/core/frontend/services/themes/storage.js @@ -69,17 +69,18 @@ module.exports = { return themeLoader.loadOneTheme(shortName); }) .then((loadedTheme) => { + const overrideTheme = (shortName === settingsCache.get('active_theme')); // CASE: if this is the active theme, we are overriding - if (shortName === settingsCache.get('active_theme')) { + if (overrideTheme) { debug('Activating theme (method C, on API "override")', shortName); activate(loadedTheme, checkedTheme); - - // CASE: clear cache - this.headers.cacheInvalidate = true; } // @TODO: unify the name across gscan and Ghost! - return toJSON(shortName, checkedTheme); + return { + themeOverridden: overrideTheme, + theme: toJSON(shortName, checkedTheme) + }; }) .finally(() => { // @TODO: we should probably do this as part of saving the theme diff --git a/core/server/api/v0.1/themes.js b/core/server/api/v0.1/themes.js index 293ac83184..4e4e9b0a41 100644 --- a/core/server/api/v0.1/themes.js +++ b/core/server/api/v0.1/themes.js @@ -74,7 +74,7 @@ themes = { .then(() => { return themeService.storage.setFromZip(zip); }) - .then((theme) => { + .then(({theme}) => { common.events.emit('theme.uploaded'); return theme; }); diff --git a/core/server/api/v2/themes.js b/core/server/api/v2/themes.js index 19b16ea1dc..bc5c6301cd 100644 --- a/core/server/api/v2/themes.js +++ b/core/server/api/v2/themes.js @@ -61,7 +61,11 @@ module.exports = { }; return themeService.storage.setFromZip(zip) - .then((theme) => { + .then(({theme, themeOverriden}) => { + if (themeOverriden) { + // CASE: clear cache + this.headers.cacheInvalidate = true; + } common.events.emit('theme.uploaded'); return theme; });