diff --git a/src/App.js b/src/App.js index 273b3e3bc..384e89c64 100644 --- a/src/App.js +++ b/src/App.js @@ -74,7 +74,7 @@ export default { created() { // Load the locale from the storage const val = useSyncConfigStore().mergedConfig.interfaceLanguage - this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'interfaceLanguage', value: val }) document.getElementById('modal').classList = ['-' + this.layoutType] // Create bound handlers diff --git a/src/App.scss b/src/App.scss index 1eee63a7e..b36e702d5 100644 --- a/src/App.scss +++ b/src/App.scss @@ -797,14 +797,17 @@ option { } .notice-dismissible { - padding-right: 4rem; - position: relative; + display: flex; + padding: 0.75em 1em; + align-items: baseline; + line-height: 1.5; + + span { + display: block; + flex: 1 1 auto; + } .dismiss { - position: absolute; - top: 0; - right: 0; - padding: 0.5em; color: inherit; } } diff --git a/src/components/extra_notifications/extra_notifications.js b/src/components/extra_notifications/extra_notifications.js index 85f4f72bd..bfe8dbe42 100644 --- a/src/components/extra_notifications/extra_notifications.js +++ b/src/components/extra_notifications/extra_notifications.js @@ -61,8 +61,8 @@ const ExtraNotifications = { return useInterfaceStore().openSettingsModalTab('notifications') }, dismissConfigurationTip() { - return this.$store.dispatch('setOption', { - name: 'showExtraNotificationsTip', + return useSyncConfigStore().setSimplePrefAndSave({ + path: 'showExtraNotificationsTip', value: false, }) }, diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 9e5901f24..ae6264217 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -84,8 +84,8 @@ const NavPanel = { this.editMode = !this.editMode }, toggleCollapse() { - useSyncConfigStore().setPreference({ - path: 'simple.collapseNav', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'collapseNav', value: !this.collapsed, }) useSyncConfigStore().pushSyncConfig() diff --git a/src/components/notifications/notification_filters.vue b/src/components/notifications/notification_filters.vue index 5508e03ac..a29e6bb85 100644 --- a/src/components/notifications/notification_filters.vue +++ b/src/components/notifications/notification_filters.vue @@ -124,8 +124,8 @@ export default { }, methods: { toggleNotificationFilter(type) { - this.$store.dispatch('setOption', { - name: 'notificationVisibility', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'notificationVisibility', value: { ...this.filters, [type]: !this.filters[type], diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 3584c66ab..df2792c80 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -819,8 +819,8 @@ const PostStatusForm = { } }, dismissScopeNotice() { - this.$store.dispatch('setOption', { - name: 'hideScopeNotice', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'hideScopeNotice', value: true, }) }, diff --git a/src/components/post_status_form/post_status_form.scss b/src/components/post_status_form/post_status_form.scss index 641dc6dac..c7fdb0806 100644 --- a/src/components/post_status_form/post_status_form.scss +++ b/src/components/post_status_form/post_status_form.scss @@ -111,7 +111,6 @@ .visibility-notice { border: 1px solid var(--border); border-radius: var(--roundness); - padding: 0.5em 1em } .visibility-notice.edit-warning { diff --git a/src/components/quick_filter_settings/quick_filter_settings.js b/src/components/quick_filter_settings/quick_filter_settings.js index 84abeec72..6dc2b57af 100644 --- a/src/components/quick_filter_settings/quick_filter_settings.js +++ b/src/components/quick_filter_settings/quick_filter_settings.js @@ -20,8 +20,8 @@ const QuickFilterSettings = { }, methods: { setReplyVisibility(visibility) { - this.$store.dispatch('setOption', { - name: 'replyVisibility', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'replyVisibility', value: visibility, }) this.$store.dispatch('queueFlushAll') @@ -87,9 +87,9 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMedia - this.$store.dispatch('setOption', { name: 'hideAttachments', value }) - this.$store.dispatch('setOption', { - name: 'hideAttachmentsInConv', + useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value }) + useSyncConfigStore().setSimplePrefAndSave({ + path: 'hideAttachmentsInConv', value, }) }, @@ -100,8 +100,8 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMutedPosts - this.$store.dispatch('setOption', { - name: 'hideFilteredStatuses', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'hideFilteredStatuses', value, }) }, @@ -112,7 +112,7 @@ const QuickFilterSettings = { }, set() { const value = !this.muteBotStatuses - this.$store.dispatch('setOption', { name: 'muteBotStatuses', value }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'muteBotStatuses', value }) }, }, muteSensitiveStatuses: { @@ -121,8 +121,8 @@ const QuickFilterSettings = { }, set() { const value = !this.muteSensitiveStatuses - this.$store.dispatch('setOption', { - name: 'muteSensitiveStatuses', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'muteSensitiveStatuses', value, }) }, diff --git a/src/components/quick_view_settings/quick_view_settings.js b/src/components/quick_view_settings/quick_view_settings.js index d22e10495..3d2033d2a 100644 --- a/src/components/quick_view_settings/quick_view_settings.js +++ b/src/components/quick_view_settings/quick_view_settings.js @@ -42,8 +42,8 @@ const QuickViewSettings = { return this.mergedConfig.conversationDisplay }, set(value) { - useSyncConfigStore().setPreference({ - path: 'simple.conversationDisplay', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'conversationDisplay', value, }) }, @@ -54,7 +54,7 @@ const QuickViewSettings = { }, set() { const value = !this.autoUpdate - useSyncConfigStore().setPreference({ path: 'simple.streaming', value }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'streaming', value }) }, }, collapseWithSubjects: { @@ -63,8 +63,8 @@ const QuickViewSettings = { }, set() { const value = !this.collapseWithSubjects - useSyncConfigStore().setPreference({ - path: 'simple.collapseMessageWithSubject', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'collapseMessageWithSubject', value, }) }, @@ -75,8 +75,8 @@ const QuickViewSettings = { }, set() { const value = !this.showUserAvatars - useSyncConfigStore().setPreference({ - path: 'simple.mentionLinkShowAvatar', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'mentionLinkShowAvatar', value, }) }, @@ -87,8 +87,8 @@ const QuickViewSettings = { }, set() { const value = !this.muteBotStatuses - useSyncConfigStore().setPreference({ - path: 'simple.muteBotStatuses', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'muteBotStatuses', value, }) }, @@ -99,8 +99,8 @@ const QuickViewSettings = { }, set() { const value = !this.muteSensitiveStatuses - useSyncConfigStore().setPreference({ - path: 'simple.muteSensitiveStatuses', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'muteSensitiveStatuses', value, }) }, diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index 654eacaa0..f93e3eb59 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -259,7 +259,7 @@ export default { const writePath = `simple.${readPath}` if (!this.timedApplyMode) { - useSyncConfigStore().setPreference({ path: writePath, value }) + useSyncConfigStore().setSimplePrefAndSave({ path: writePath, value }) useSyncConfigStore().pushSyncConfig() } else { if (useInterfaceStore().temporaryChangesTimeoutId !== null) { diff --git a/src/components/settings_modal/settings_modal.js b/src/components/settings_modal/settings_modal.js index 866459314..25c508bef 100644 --- a/src/components/settings_modal/settings_modal.js +++ b/src/components/settings_modal/settings_modal.js @@ -195,8 +195,8 @@ const SettingsModal = { return useSyncConfigStore().mergedConfig.expertLevel > 0 }, set(value) { - useSyncConfigStore().setPreference({ - path: 'simple.expertLevel', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'expertLevel', value: value ? 1 : 0, }) }, diff --git a/src/components/settings_modal/tabs/clutter_tab.js b/src/components/settings_modal/tabs/clutter_tab.js index f81ad7040..510425e2d 100644 --- a/src/components/settings_modal/tabs/clutter_tab.js +++ b/src/components/settings_modal/tabs/clutter_tab.js @@ -52,8 +52,8 @@ const ClutterTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.$store.dispatch('setOption', { - name: 'onMuteDefaultAction', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'onMuteDefaultAction', value: realValue, }) }, @@ -72,8 +72,8 @@ const ClutterTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.$store.dispatch('setOption', { - name: 'onBlockDefaultAction', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'onBlockDefaultAction', value: realValue, }) }, @@ -90,8 +90,8 @@ const ClutterTab = { }, methods: { ...mapActions(useSyncConfigStore, [ - 'setPreference', - 'unsetPreference', + 'setSimplePrefAndSave', + 'unsetSimplePrefAndSave', 'pushSyncConfig', ]), getDatetimeLocal(timestamp) { @@ -138,7 +138,7 @@ const ClutterTab = { filter.order = this.muteFilters.length + 2 this.muteFiltersDraftObject[newId] = filter - this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) + this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) this.pushSyncConfig() }, exportFilter(id) { @@ -154,18 +154,18 @@ const ClutterTab = { const newId = uuidv4() this.muteFiltersDraftObject[newId] = filter - this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) + this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) this.pushSyncConfig() }, deleteFilter(id) { delete this.muteFiltersDraftObject[id] - this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) + this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) this.pushSyncConfig() }, purgeExpiredFilters() { this.muteFiltersExpired.forEach(([id]) => { delete this.muteFiltersDraftObject[id] - this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) + this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) }) this.pushSyncConfig() }, @@ -189,8 +189,8 @@ const ClutterTab = { this.muteFiltersDraftDirty[id] = true }, saveFilter(id) { - this.setPreference({ - path: 'simple.muteFilters.' + id, + this.setSimplePrefAndSave({ + path: 'muteFilters.' + id, value: this.muteFiltersDraftObject[id], }) this.pushSyncConfig() diff --git a/src/components/settings_modal/tabs/composing_tab.js b/src/components/settings_modal/tabs/composing_tab.js index e4ce20a1e..264c4d277 100644 --- a/src/components/settings_modal/tabs/composing_tab.js +++ b/src/components/settings_modal/tabs/composing_tab.js @@ -120,8 +120,8 @@ const ComposingTab = { return useSyncConfigStore().mergedConfig.interfaceLanguage }, set: function (val) { - this.$store.dispatch('setOption', { - name: 'interfaceLanguage', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'interfaceLanguage', value: val, }) }, @@ -172,8 +172,8 @@ const ComposingTab = { }) }, updateFont(key, value) { - this.$store.dispatch('setOption', { - name: 'theme3hacks', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'theme3hacks', value: { ...this.mergedConfig.theme3hacks, fonts: { diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js index a0544dd30..04dfe76bd 100644 --- a/src/components/settings_modal/tabs/filtering_tab.js +++ b/src/components/settings_modal/tabs/filtering_tab.js @@ -36,11 +36,11 @@ const FilteringTab = { label: this.$t(`user_card.mute_block_${mode}`), })), muteFiltersDraftObject: cloneDeep( - useSyncConfigStore().prefsStorage.simple.muteFilters, + this.prefsStorage.simple.muteFilters, ), muteFiltersDraftDirty: Object.fromEntries( Object.entries( - useSyncConfigStore().prefsStorage.simple.muteFilters, + this.prefsStorage.simple.muteFilters, ).map(([k]) => [k, false]), ), exportedFilter: null, @@ -112,8 +112,8 @@ const FilteringTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.$store.dispatch('setOption', { - name: 'onMuteDefaultAction', + this.setPreference({ + path: 'simple.onMuteDefaultAction', value: realValue, }) }, @@ -132,8 +132,8 @@ const FilteringTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.$store.dispatch('setOption', { - name: 'onBlockDefaultAction', + this.setPreference({ + path: 'simple.onBlockDefaultAction', value: realValue, }) }, @@ -151,7 +151,9 @@ const FilteringTab = { methods: { ...mapActions(useSyncConfigStore, [ 'setPreference', + 'setPrefAndSave', 'unsetPreference', + 'unsetPrefAndSave', 'pushSyncConfig', ]), getDatetimeLocal(timestamp) { @@ -198,8 +200,7 @@ const FilteringTab = { filter.order = this.muteFilters.length + 2 this.muteFiltersDraftObject[newId] = filter - this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) - this.pushSyncConfig() + this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) }, exportFilter(id) { this.exportedFilter = { ...this.muteFiltersDraftObject[id] } @@ -214,13 +215,11 @@ const FilteringTab = { const newId = uuidv4() this.muteFiltersDraftObject[newId] = filter - this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) - this.pushSyncConfig() + this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) }, deleteFilter(id) { delete this.muteFiltersDraftObject[id] - this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) - this.pushSyncConfig() + this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) }, purgeExpiredFilters() { this.muteFiltersExpired.forEach(([id]) => { @@ -249,11 +248,10 @@ const FilteringTab = { this.muteFiltersDraftDirty[id] = true }, saveFilter(id) { - this.setPreference({ - path: 'simple.muteFilters.' + id, + this.setPrefAndSave({ + path: 'muteFilters.' + id, value: this.muteFiltersDraftObject[id], }) - this.pushSyncConfig() this.muteFiltersDraftDirty[id] = false }, }, diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js index ea939193e..4a618bd67 100644 --- a/src/components/settings_modal/tabs/general_tab.js +++ b/src/components/settings_modal/tabs/general_tab.js @@ -10,8 +10,8 @@ import SharedComputedObject from '../helpers/shared_computed_object.js' import UnitSetting from '../helpers/unit_setting.vue' import { useInstanceStore } from 'src/stores/instance.js' -import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import localeService from 'src/services/locale/locale.service.js' @@ -41,8 +41,8 @@ const GeneralTab = { return useSyncConfigStore().mergedConfig.interfaceLanguage }, set: function (val) { - this.$store.dispatch('setOption', { - name: 'interfaceLanguage', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'interfaceLanguage', value: val, }) }, @@ -69,8 +69,8 @@ const GeneralTab = { }) }, updateFont(key, value) { - this.$store.dispatch('setOption', { - name: 'theme3hacks', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'theme3hacks', value: { ...this.mergedConfig.theme3hacks, fonts: { diff --git a/src/components/settings_modal/tabs/posts_tab.js b/src/components/settings_modal/tabs/posts_tab.js index 268a0a56f..bf0b8d200 100644 --- a/src/components/settings_modal/tabs/posts_tab.js +++ b/src/components/settings_modal/tabs/posts_tab.js @@ -67,8 +67,8 @@ const GeneralTab = { }, methods: { updateFont(key, value) { - this.$store.dispatch('setOption', { - name: 'theme3hacks', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'theme3hacks', value: { ...this.mergedConfig.theme3hacks, fonts: { diff --git a/src/components/update_notification/update_notification.js b/src/components/update_notification/update_notification.js index 78aaa79e8..7134019e1 100644 --- a/src/components/update_notification/update_notification.js +++ b/src/components/update_notification/update_notification.js @@ -57,8 +57,8 @@ const UpdateNotification = { flag: 'updateCounter', value: CURRENT_UPDATE_COUNTER, }) - useSyncConfigStore().setPreference({ - path: 'simple.dontShowUpdateNotifs', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'dontShowUpdateNotifs', value: true, }) useSyncConfigStore().pushSyncConfig() diff --git a/src/components/user_timed_filter_modal/user_timed_filter_modal.js b/src/components/user_timed_filter_modal/user_timed_filter_modal.js index a06c5db59..558891541 100644 --- a/src/components/user_timed_filter_modal/user_timed_filter_modal.js +++ b/src/components/user_timed_filter_modal/user_timed_filter_modal.js @@ -84,16 +84,16 @@ const UserTimedFilterModal = { if (this.isMute) { this.$store.dispatch('muteUser', this.requestBody) if (this.dontAskAgain) { - this.$store.dispatch('setOption', { - name: 'onMuteDefaultAction', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'onMuteDefaultAction', value: this.expiryString, }) } } else { this.$store.dispatch('blockUser', this.requestBody) if (this.dontAskAgain) { - this.$store.dispatch('setOption', { - name: 'onBlockDefaultAction', + useSyncConfigStore().setSimplePrefAndSave({ + path: 'onBlockDefaultAction', value: this.expiryString, }) } diff --git a/src/lib/language.js b/src/lib/language.js index 68e3a0989..beabfcca8 100644 --- a/src/lib/language.js +++ b/src/lib/language.js @@ -15,8 +15,7 @@ export const piniaLanguagePlugin = ({ store, options }) => { if (name === 'setPreference') { const { path, value } = args[0] if (path === 'simple.interfaceLanguage') { - useI18nStore().setLanguage(value) - messages.setLanguage(this.i18n, value) + messages.setLanguage(useI18nStore().i18n, value) useEmojiStore().loadUnicodeEmojiData(value) Cookies.set( BACKEND_LANGUAGE_COOKIE_NAME, diff --git a/src/modules/config_declaration.js b/src/modules/config_declaration.js index bf6a5cd7b..334b51c2b 100644 --- a/src/modules/config_declaration.js +++ b/src/modules/config_declaration.js @@ -10,7 +10,7 @@ const simpleDeclaration = { store: 'server-side', migrationFlag: 'configMigration', migration(serverside, rootState) { - serverside.setPreference({ path: 'simple.' + field, value: rootState.config[oldField ?? field] }) + serverside.setSimplePrefAndSave({ path: field, value: rootState.config[oldField ?? field] }) } } */ diff --git a/src/modules/notifications.js b/src/modules/notifications.js index 9507177a2..ae6f71b70 100644 --- a/src/modules/notifications.js +++ b/src/modules/notifications.js @@ -118,6 +118,7 @@ export const notifications = { commit('addNewNotifications', { notifications: [notification] }) maybeShowNotification( + useSyncConfigStore().mergedConfig.notificationVisibility, store, Object.values(useSyncConfigStore().prefsStorage.simple.muteFilters), notification, diff --git a/src/modules/users.js b/src/modules/users.js index a22c157ed..a8752feff 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -725,7 +725,7 @@ const users = { Object.keys( useSyncConfigStore().prefsStorage.simple.muteFilters ).forEach(key => { - useSyncConfigStore().unsetPreference({ path: 'simple.muteFilters.' + key, value: null }) + useSyncConfigStore().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null }) }) // Reset flag to 0 to re-run migrations diff --git a/src/stores/interface.js b/src/stores/interface.js index dfe788262..e61186e7e 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -226,14 +226,14 @@ export const useInterfaceStore = defineStore('interface', { try { const value = await getResourcesIndex('/static/palettes/index.json') useInstanceStore().set({ - name: 'palettesIndex', + path: 'palettesIndex', value, }) return value } catch (e) { console.error('Could not fetch palettes index', e) useInstanceStore().set({ - name: 'palettesIndex', + path: 'palettesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -243,7 +243,8 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - window.vuex.commit('setOption', { name: 'palette', value }) + useSyncConfigStore().setPreference({ path: 'simple.palette', value }) + useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) }, @@ -251,7 +252,8 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - window.vuex.commit('setOption', { name: 'paletteCustomData', value }) + useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value }) + useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) }, @@ -261,12 +263,12 @@ export const useInterfaceStore = defineStore('interface', { '/static/styles/index.json', deserialize, ) - useInstanceStore().set({ name: 'stylesIndex', value }) + useInstanceStore().set({ path: 'stylesIndex', value }) return value } catch (e) { console.error('Could not fetch styles index', e) useInstanceStore().set({ - name: 'stylesIndex', + path: 'simple.stylesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -277,7 +279,8 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() this.resetThemeV3Palette() - window.vuex.commit('setOption', { name: 'style', value }) + useSyncConfigStore().setPreference({ path: 'simple.style', value }) + useSyncConfigStore().pushSyncConfig() this.useStylePalette = true this.applyTheme({ recompile: true }).then(() => { @@ -289,7 +292,8 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() this.resetThemeV3Palette() - window.vuex.commit('setOption', { name: 'styleCustomData', value }) + useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value }) + useSyncConfigStore().pushSyncConfig() this.useStylePalette = true this.applyTheme({ recompile: true }).then(() => { @@ -299,12 +303,12 @@ export const useInterfaceStore = defineStore('interface', { async fetchThemesIndex() { try { const value = await getResourcesIndex('/static/styles.json') - useInstanceStore().set({ name: 'themesIndex', value }) + useInstanceStore().set({ path: 'simple.themesIndex', value }) return value } catch (e) { console.error('Could not fetch themes index', e) useInstanceStore().set({ - name: 'themesIndex', + path: 'themesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -315,7 +319,8 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - window.vuex.commit('setOption', { name: 'theme', value }) + useSyncConfigStore().setPreference({ path: 'simple.theme', value }) + useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) }, @@ -324,29 +329,33 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - window.vuex.commit('setOption', { name: 'customTheme', value }) - window.vuex.commit('setOption', { name: 'customThemeSource', value }) + useSyncConfigStore().setPreference({ path: 'simple.customTheme', value }) + useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value }) + useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) }, resetThemeV3() { - window.vuex.commit('setOption', { name: 'style', value: null }) - window.vuex.commit('setOption', { name: 'styleCustomData', value: null }) + useSyncConfigStore().setPreference({ path: 'simple.style', value: null }) + useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null }) + useSyncConfigStore().pushSyncConfig() }, resetThemeV3Palette() { - window.vuex.commit('setOption', { name: 'palette', value: null }) - window.vuex.commit('setOption', { - name: 'paletteCustomData', + useSyncConfigStore().setPreference({ path: 'simple.palette', value: null }) + useSyncConfigStore().setPreference({ + path: 'simple.paletteCustomData', value: null, }) + useSyncConfigStore().pushSyncConfig() }, resetThemeV2() { - window.vuex.commit('setOption', { name: 'theme', value: null }) - window.vuex.commit('setOption', { name: 'customTheme', value: null }) - window.vuex.commit('setOption', { - name: 'customThemeSource', + useSyncConfigStore().setPreference({ path: 'simple.theme', value: null }) + useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null }) + useSyncConfigStore().setPreference({ + path: 'simple.customThemeSource', value: null, }) + useSyncConfigStore().pushSyncConfig() }, async getThemeData() { const getData = async (resource, index, customData, name) => { @@ -512,10 +521,11 @@ export const useInterfaceStore = defineStore('interface', { ) if (this.useStylePalette) { - window.vuex.commit('setOption', { - name: 'palette', + useSyncConfigStore().setPreference({ + path: 'simple.palette', value: firstStylePaletteName, }) + useSyncConfigStore().pushSyncConfig() } this.paletteNameUsed = palette.nameUsed diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 009ccbce4..91394139f 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -417,6 +417,14 @@ export const useSyncConfigStore = defineStore('sync_config', { this.flagStorage[flag] = value this.dirty = true }, + setSimplePrefAndSave({ path, value }) { + this.setPreference({ path: `simple.${path}`, value }) + this.pushSyncConfig() + }, + unsetSimplePrefAndSave({ path }) { + this.unsetPreference({ path: `simple.${path}` }) + this.pushSyncConfig() + }, setPreference({ path, value }) { if (path.startsWith('_')) { throw new Error( @@ -472,7 +480,7 @@ export const useSyncConfigStore = defineStore('sync_config', { `Calling unset on depth > 3 (path: ${path}) is not allowed`, ) } - unset(this.prefsStorage, path, value) + unset(this.prefsStorage, path) this.prefsStorage._journal = [ ...this.prefsStorage._journal, { operation: 'unset', path, args: [], timestamp: Date.now() },