diff options
| author | Shpuld Shpludson <shp@cock.li> | 2020-02-28 20:27:02 +0000 |
|---|---|---|
| committer | Shpuld Shpludson <shp@cock.li> | 2020-02-28 20:27:02 +0000 |
| commit | 1b9805b550444403792db2304b5a6d5681e8f30d (patch) | |
| tree | 052299372a386107d277c414148c9f3d63408c1c /src/modules/instance.js | |
| parent | 3ab128e73924ce34d190ff609cb9b081cdffe402 (diff) | |
| parent | 57e72b48c1fec74a860fd5abc75f0e9c4986c3f6 (diff) | |
Merge branch 'develop' into 'master'
Update master with 2.0.0
See merge request pleroma/pleroma-fe!1074
Diffstat (limited to 'src/modules/instance.js')
| -rw-r--r-- | src/modules/instance.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/modules/instance.js b/src/modules/instance.js index 625323b9..ffece311 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -1,5 +1,6 @@ import { set } from 'vue' -import { setPreset } from '../services/style_setter/style_setter.js' +import { getPreset, applyTheme } from '../services/style_setter/style_setter.js' +import { CURRENT_VERSION } from '../services/theme_data/theme_data.service.js' import { instanceDefaultProperties } from './config.js' const defaultState = { @@ -10,6 +11,7 @@ const defaultState = { textlimit: 5000, server: 'http://localhost:4040/', theme: 'pleroma-dark', + themeData: undefined, background: '/static/aurora_borealis.jpg', logo: '/static/logo.png', logoMask: true, @@ -96,6 +98,9 @@ const instance = { dispatch('initializeSocket') } break + case 'theme': + dispatch('setTheme', value) + break } }, async getStaticEmoji ({ commit }) { @@ -147,9 +152,23 @@ const instance = { } }, - setTheme ({ commit }, themeName) { + setTheme ({ commit, rootState }, themeName) { commit('setInstanceOption', { name: 'theme', value: themeName }) - return setPreset(themeName, commit) + getPreset(themeName) + .then(themeData => { + commit('setInstanceOption', { name: 'themeData', value: themeData }) + // No need to apply theme if there's user theme already + const { customTheme } = rootState.config + if (customTheme) return + + // New theme presets don't have 'theme' property, they use 'source' + const themeSource = themeData.source + if (!themeData.theme || (themeSource && themeSource.themeEngineVersion === CURRENT_VERSION)) { + applyTheme(themeSource) + } else { + applyTheme(themeData.theme) + } + }) }, fetchEmoji ({ dispatch, state }) { if (!state.customEmojiFetched) { |
