diff options
| author | Henry Jameson <me@hjkos.com> | 2024-07-17 22:10:11 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2024-07-17 22:10:11 +0300 |
| commit | d2683a672859cb0fb46037540f62f4fdb07407c1 (patch) | |
| tree | 4fee2c22fed6f8e309753722f5d76ddee7f0266f /src/modules/interface.js | |
| parent | 9bbdad1a6f4c3d52569f4c58c04dace95d9a6bb3 (diff) | |
new theme selector, RC
Diffstat (limited to 'src/modules/interface.js')
| -rw-r--r-- | src/modules/interface.js | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/src/modules/interface.js b/src/modules/interface.js index a0746052..b56b60ec 100644 --- a/src/modules/interface.js +++ b/src/modules/interface.js @@ -212,12 +212,13 @@ const interfaceMod = { setLastTimeline ({ commit }, value) { commit('setLastTimeline', value) }, - setTheme ({ commit, rootState }, { themeName, themeData, recompile } = {}) { + setTheme ({ commit, rootState }, { themeName, themeData, recompile, saveData } = {}) { const { theme: instanceThemeName } = rootState.instance const { + theme: userThemeName, customTheme: userThemeSnapshot, customThemeSource: userThemeSource, forceThemeRecompilation, @@ -225,6 +226,8 @@ const interfaceMod = { theme3hacks } = rootState.config + const actualThemeName = userThemeName || instanceThemeName + const forceRecompile = forceThemeRecompilation || recompile // If we're not not forced to recompile try using @@ -236,28 +239,31 @@ const interfaceMod = { let promise = null - if (themeName) { - promise = getPreset(themeName) - .then(themeData => { - return normalizeThemeData(themeData) - }) - } else if (themeData) { + if (themeData) { promise = Promise.resolve(normalizeThemeData(themeData)) - } else { - if (userThemeSource || userThemeSnapshot) { - if (userThemeSource && userThemeSource.themeEngineVersion === CURRENT_VERSION) { - promise = Promise.resolve(normalizeThemeData(userThemeSource)) - } else { - promise = Promise.resolve(normalizeThemeData(userThemeSnapshot)) - } - } else if (instanceThemeName) { - promise = getPreset(themeName).then(themeData => normalizeThemeData(themeData)) + } else if (themeName) { + promise = getPreset(themeName).then(themeData => normalizeThemeData(themeData)) + } else if (userThemeSource || userThemeSnapshot) { + if (userThemeSource && userThemeSource.themeEngineVersion === CURRENT_VERSION) { + promise = Promise.resolve(normalizeThemeData(userThemeSource)) + } else { + promise = Promise.resolve(normalizeThemeData(userThemeSnapshot)) } + } else if (actualThemeName && actualThemeName !== 'custom') { + promise = getPreset(actualThemeName).then(themeData => normalizeThemeData(themeData)) + } else { + throw new Error('Cannot load any theme!') } promise .then(realThemeData => { const theme2ruleset = convertTheme2To3(realThemeData) + + if (saveData) { + commit('setOption', { name: 'theme', value: themeName || actualThemeName }) + commit('setOption', { name: 'customTheme', value: realThemeData }) + commit('setOption', { name: 'customThemeSource', value: realThemeData }) + } const hacks = [] Object.entries(theme3hacks).forEach(([key, value]) => { |
