diff --git a/src/App.js b/src/App.js index 6aeba32b2..879da48a7 100644 --- a/src/App.js +++ b/src/App.js @@ -25,6 +25,7 @@ import { useInterfaceStore } from 'src/stores/interface.js' import { useShoutStore } from 'src/stores/shout.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { applyStyleConfig } from 'src/services/style_setter/style_setter.js' import { getOrCreateServiceWorker } from 'src/services/sw/sw' import { windowHeight, @@ -76,7 +77,9 @@ export default { }, created() { document.getElementById('modal').classList = ['-' + this.layoutType] + useI18nStore().setLanguage() + applyStyleConfig(useSyncConfigStore().mergedConfig) // Create bound handlers this.updateScrollState = throttle(this.scrollHandler, 200) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 771c0e233..ed8fbb080 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -18,7 +18,7 @@ config.autoAddCss = false import App from '../App.vue' import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js' import FaviconService from '../services/favicon_service/favicon_service.js' -import { applyConfig } from '../services/style_setter/style_setter.js' +import { applyStyleConfig } from '../services/style_setter/style_setter.js' import { initServiceWorker, updateFocus } from '../services/sw/sw.js' import { windowHeight, @@ -26,12 +26,13 @@ import { } from '../services/window_utils/window_utils' import routes from './routes' -import { useAnnouncementsStore } from 'src/stores/announcements' -import { useAuthFlowStore } from 'src/stores/auth_flow' -import { useI18nStore } from 'src/stores/i18n' -import { useInstanceStore } from 'src/stores/instance' -import { useInterfaceStore } from 'src/stores/interface' -import { useOAuthStore } from 'src/stores/oauth' +import { useAnnouncementsStore } from 'src/stores/announcements.js' +import { useAuthFlowStore } from 'src/stores/auth_flow.js' +import { useI18nStore } from 'src/stores/i18n.js' +import { useInstanceStore } from 'src/stores/instance.js' +import { useInterfaceStore } from 'src/stores/interface.js' +import { useOAuthStore } from 'src/stores/oauth.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import VBodyScrollLock from 'src/directives/body_scroll_lock' import { @@ -164,7 +165,6 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { } else { config = { ...staticConfig, ...apiConfig } } - console.trace(config) const copyInstanceIdentityOption = (path) => { if (get(config, path) !== undefined) { @@ -567,7 +567,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { return Promise.reject(e) } - applyConfig(store.state.config, i18n.global) + applyStyleConfig(useSyncConfigStore().mergedConfig) // Now we can try getting the server settings and logging in // Most of these are preloaded into the index.html so blocking is minimized diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js index b0f980eac..25ad6b665 100644 --- a/src/components/settings_modal/tabs/appearance_tab.js +++ b/src/components/settings_modal/tabs/appearance_tab.js @@ -281,7 +281,7 @@ const AppearanceTab = { }, instanceWallpaperUsed() { return ( - useInstanceStore().background && + this.instanceWallpaper && !this.$store.state.users.currentUser.background_image ) }, @@ -312,9 +312,9 @@ const AppearanceTab = { }, onImport(parsed, filename) { if (filename.endsWith('.json')) { - useInterfaceStore().setThemeCustom(parsed.source || parsed.theme) + this.setThemeCustom(parsed.source || parsed.theme) } else if (filename.endsWith('.iss')) { - useInterfaceStore().setStyleCustom(parsed) + this.setStyleCustom(parsed) } }, onImportFailure(result) { @@ -336,25 +336,42 @@ const AppearanceTab = { } }, isThemeActive(key) { - return key === (this.mergedConfig.theme || useInstanceStore().theme) + return ( + key === + (useSyncConfigStore().mergedConfig.theme) + ) }, isStyleActive(key) { - return key === (this.mergedConfig.style || useInstanceStore().style) + return ( + key === + (useSyncConfigStore().mergedConfig.style) + ) }, isPaletteActive(key) { - return key === (this.mergedConfig.palette || useInstanceStore().palette) + return ( + key === + (useSyncConfigStore().mergedConfig.palette || + useInstanceStore().palette) + ) }, - ...mapActions(useInterfaceStore, ['setStyle', 'setTheme']), - setPalette(name, data) { - useInterfaceStore().setPalette(name) + ...mapActions(useInterfaceStore, [ + 'setStyle', + 'setStyleCustom', + 'setPalette', + 'setPaletteCustom', + 'setTheme', + 'setThemeCustom', + ]), + setLocalPalette(name, data) { + this.setPalette(name) this.userPalette = data }, - setPaletteCustom(data) { - useInterfaceStore().setPaletteCustom(data) + setLocalPaletteCustom(data) { + this.setPaletteCustom(data) this.userPalette = data }, resetTheming() { - useInterfaceStore().setStyle('stock') + this.setStyle('stock') }, previewTheme(key, version, input) { let theme3 diff --git a/src/components/settings_modal/tabs/appearance_tab.vue b/src/components/settings_modal/tabs/appearance_tab.vue index 75a06388d..85ca4be89 100644 --- a/src/components/settings_modal/tabs/appearance_tab.vue +++ b/src/components/settings_modal/tabs/appearance_tab.vue @@ -54,7 +54,7 @@ :key="style.key" :data-theme-key="style.key" class="button-default theme-preview" - :class="{ toggled: isThemeActive(style.key), disabled: switchInProgress }" + :class="{ toggled: isStyleActive(style.key), disabled: switchInProgress }" :disabled="switchInProgress" @click="style.version === 'v2' ? setTheme(style.key) : setStyle(style.key)" > @@ -90,7 +90,7 @@ class="btn button-default palette-entry" :class="{ toggled: isPaletteActive(p.key), disabled: switchInProgress }" :disabled="switchInProgress" - @click="() => setPalette(p.key, p)" + @click="() => setLocalPalette(p.key, p)" >