diff --git a/src/App.js b/src/App.js index 384e89c64..273b3e3bc 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 - useSyncConfigStore().setSimplePrefAndSave({ path: 'interfaceLanguage', value: val }) + this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) document.getElementById('modal').classList = ['-' + this.layoutType] // Create bound handlers diff --git a/src/App.scss b/src/App.scss index b36e702d5..1eee63a7e 100644 --- a/src/App.scss +++ b/src/App.scss @@ -797,17 +797,14 @@ option { } .notice-dismissible { - display: flex; - padding: 0.75em 1em; - align-items: baseline; - line-height: 1.5; - - span { - display: block; - flex: 1 1 auto; - } + padding-right: 4rem; + position: relative; .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 bfe8dbe42..85f4f72bd 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 useSyncConfigStore().setSimplePrefAndSave({ - path: 'showExtraNotificationsTip', + return this.$store.dispatch('setOption', { + name: 'showExtraNotificationsTip', value: false, }) }, diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index ae6264217..9e5901f24 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().setSimplePrefAndSave({ - path: 'collapseNav', + useSyncConfigStore().setPreference({ + path: 'simple.collapseNav', value: !this.collapsed, }) useSyncConfigStore().pushSyncConfig() diff --git a/src/components/notifications/notification_filters.vue b/src/components/notifications/notification_filters.vue index a29e6bb85..5508e03ac 100644 --- a/src/components/notifications/notification_filters.vue +++ b/src/components/notifications/notification_filters.vue @@ -124,8 +124,8 @@ export default { }, methods: { toggleNotificationFilter(type) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'notificationVisibility', + this.$store.dispatch('setOption', { + name: '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 df2792c80..3584c66ab 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() { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'hideScopeNotice', + this.$store.dispatch('setOption', { + name: '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 c7fdb0806..641dc6dac 100644 --- a/src/components/post_status_form/post_status_form.scss +++ b/src/components/post_status_form/post_status_form.scss @@ -111,6 +111,7 @@ .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 6dc2b57af..84abeec72 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) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'replyVisibility', + this.$store.dispatch('setOption', { + name: 'replyVisibility', value: visibility, }) this.$store.dispatch('queueFlushAll') @@ -87,9 +87,9 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMedia - useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value }) - useSyncConfigStore().setSimplePrefAndSave({ - path: 'hideAttachmentsInConv', + this.$store.dispatch('setOption', { name: 'hideAttachments', value }) + this.$store.dispatch('setOption', { + name: 'hideAttachmentsInConv', value, }) }, @@ -100,8 +100,8 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMutedPosts - useSyncConfigStore().setSimplePrefAndSave({ - path: 'hideFilteredStatuses', + this.$store.dispatch('setOption', { + name: 'hideFilteredStatuses', value, }) }, @@ -112,7 +112,7 @@ const QuickFilterSettings = { }, set() { const value = !this.muteBotStatuses - useSyncConfigStore().setSimplePrefAndSave({ path: 'muteBotStatuses', value }) + this.$store.dispatch('setOption', { name: 'muteBotStatuses', value }) }, }, muteSensitiveStatuses: { @@ -121,8 +121,8 @@ const QuickFilterSettings = { }, set() { const value = !this.muteSensitiveStatuses - useSyncConfigStore().setSimplePrefAndSave({ - path: 'muteSensitiveStatuses', + this.$store.dispatch('setOption', { + name: '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 3d2033d2a..d22e10495 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().setSimplePrefAndSave({ - path: 'conversationDisplay', + useSyncConfigStore().setPreference({ + path: 'simple.conversationDisplay', value, }) }, @@ -54,7 +54,7 @@ const QuickViewSettings = { }, set() { const value = !this.autoUpdate - useSyncConfigStore().setSimplePrefAndSave({ path: 'streaming', value }) + useSyncConfigStore().setPreference({ path: 'simple.streaming', value }) }, }, collapseWithSubjects: { @@ -63,8 +63,8 @@ const QuickViewSettings = { }, set() { const value = !this.collapseWithSubjects - useSyncConfigStore().setSimplePrefAndSave({ - path: 'collapseMessageWithSubject', + useSyncConfigStore().setPreference({ + path: 'simple.collapseMessageWithSubject', value, }) }, @@ -75,8 +75,8 @@ const QuickViewSettings = { }, set() { const value = !this.showUserAvatars - useSyncConfigStore().setSimplePrefAndSave({ - path: 'mentionLinkShowAvatar', + useSyncConfigStore().setPreference({ + path: 'simple.mentionLinkShowAvatar', value, }) }, @@ -87,8 +87,8 @@ const QuickViewSettings = { }, set() { const value = !this.muteBotStatuses - useSyncConfigStore().setSimplePrefAndSave({ - path: 'muteBotStatuses', + useSyncConfigStore().setPreference({ + path: 'simple.muteBotStatuses', value, }) }, @@ -99,8 +99,8 @@ const QuickViewSettings = { }, set() { const value = !this.muteSensitiveStatuses - useSyncConfigStore().setSimplePrefAndSave({ - path: 'muteSensitiveStatuses', + useSyncConfigStore().setPreference({ + path: 'simple.muteSensitiveStatuses', value, }) }, diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index f93e3eb59..654eacaa0 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().setSimplePrefAndSave({ path: writePath, value }) + useSyncConfigStore().setPreference({ 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 25c508bef..866459314 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().setSimplePrefAndSave({ - path: 'expertLevel', + useSyncConfigStore().setPreference({ + path: 'simple.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 510425e2d..f81ad7040 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' } - useSyncConfigStore().setSimplePrefAndSave({ - path: 'onMuteDefaultAction', + this.$store.dispatch('setOption', { + name: 'onMuteDefaultAction', value: realValue, }) }, @@ -72,8 +72,8 @@ const ClutterTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - useSyncConfigStore().setSimplePrefAndSave({ - path: 'onBlockDefaultAction', + this.$store.dispatch('setOption', { + name: 'onBlockDefaultAction', value: realValue, }) }, @@ -90,8 +90,8 @@ const ClutterTab = { }, methods: { ...mapActions(useSyncConfigStore, [ - 'setSimplePrefAndSave', - 'unsetSimplePrefAndSave', + 'setPreference', + 'unsetPreference', 'pushSyncConfig', ]), getDatetimeLocal(timestamp) { @@ -138,7 +138,7 @@ const ClutterTab = { filter.order = this.muteFilters.length + 2 this.muteFiltersDraftObject[newId] = filter - this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) + this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) this.pushSyncConfig() }, exportFilter(id) { @@ -154,18 +154,18 @@ const ClutterTab = { const newId = uuidv4() this.muteFiltersDraftObject[newId] = filter - this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) + this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) this.pushSyncConfig() }, deleteFilter(id) { delete this.muteFiltersDraftObject[id] - this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) + this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) this.pushSyncConfig() }, purgeExpiredFilters() { this.muteFiltersExpired.forEach(([id]) => { delete this.muteFiltersDraftObject[id] - this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) + this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) }) this.pushSyncConfig() }, @@ -189,8 +189,8 @@ const ClutterTab = { this.muteFiltersDraftDirty[id] = true }, saveFilter(id) { - this.setSimplePrefAndSave({ - path: 'muteFilters.' + id, + this.setPreference({ + path: 'simple.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 264c4d277..e4ce20a1e 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) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'interfaceLanguage', + this.$store.dispatch('setOption', { + name: 'interfaceLanguage', value: val, }) }, @@ -172,8 +172,8 @@ const ComposingTab = { }) }, updateFont(key, value) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'theme3hacks', + this.$store.dispatch('setOption', { + name: '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 04dfe76bd..a0544dd30 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( - this.prefsStorage.simple.muteFilters, + useSyncConfigStore().prefsStorage.simple.muteFilters, ), muteFiltersDraftDirty: Object.fromEntries( Object.entries( - this.prefsStorage.simple.muteFilters, + useSyncConfigStore().prefsStorage.simple.muteFilters, ).map(([k]) => [k, false]), ), exportedFilter: null, @@ -112,8 +112,8 @@ const FilteringTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.setPreference({ - path: 'simple.onMuteDefaultAction', + this.$store.dispatch('setOption', { + name: 'onMuteDefaultAction', value: realValue, }) }, @@ -132,8 +132,8 @@ const FilteringTab = { if (value !== 'ask' && value !== 'forever') { realValue = '14d' } - this.setPreference({ - path: 'simple.onBlockDefaultAction', + this.$store.dispatch('setOption', { + name: 'onBlockDefaultAction', value: realValue, }) }, @@ -151,9 +151,7 @@ const FilteringTab = { methods: { ...mapActions(useSyncConfigStore, [ 'setPreference', - 'setPrefAndSave', 'unsetPreference', - 'unsetPrefAndSave', 'pushSyncConfig', ]), getDatetimeLocal(timestamp) { @@ -200,7 +198,8 @@ const FilteringTab = { filter.order = this.muteFilters.length + 2 this.muteFiltersDraftObject[newId] = filter - this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) + this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) + this.pushSyncConfig() }, exportFilter(id) { this.exportedFilter = { ...this.muteFiltersDraftObject[id] } @@ -215,11 +214,13 @@ const FilteringTab = { const newId = uuidv4() this.muteFiltersDraftObject[newId] = filter - this.setSimplePrefAndSave({ path: 'muteFilters.' + newId, value: filter }) + this.setPreference({ path: 'simple.muteFilters.' + newId, value: filter }) + this.pushSyncConfig() }, deleteFilter(id) { delete this.muteFiltersDraftObject[id] - this.unsetSimplePrefAndSave({ path: 'muteFilters.' + id, value: null }) + this.unsetPreference({ path: 'simple.muteFilters.' + id, value: null }) + this.pushSyncConfig() }, purgeExpiredFilters() { this.muteFiltersExpired.forEach(([id]) => { @@ -248,10 +249,11 @@ const FilteringTab = { this.muteFiltersDraftDirty[id] = true }, saveFilter(id) { - this.setPrefAndSave({ - path: 'muteFilters.' + id, + this.setPreference({ + path: 'simple.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 4a618bd67..ea939193e 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 { useSyncConfigStore } from 'src/stores/sync_config.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import localeService from 'src/services/locale/locale.service.js' @@ -41,8 +41,8 @@ const GeneralTab = { return useSyncConfigStore().mergedConfig.interfaceLanguage }, set: function (val) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'interfaceLanguage', + this.$store.dispatch('setOption', { + name: 'interfaceLanguage', value: val, }) }, @@ -69,8 +69,8 @@ const GeneralTab = { }) }, updateFont(key, value) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'theme3hacks', + this.$store.dispatch('setOption', { + name: '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 bf0b8d200..268a0a56f 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) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'theme3hacks', + this.$store.dispatch('setOption', { + name: '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 7134019e1..78aaa79e8 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().setSimplePrefAndSave({ - path: 'dontShowUpdateNotifs', + useSyncConfigStore().setPreference({ + path: 'simple.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 558891541..a06c5db59 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) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'onMuteDefaultAction', + this.$store.dispatch('setOption', { + name: 'onMuteDefaultAction', value: this.expiryString, }) } } else { this.$store.dispatch('blockUser', this.requestBody) if (this.dontAskAgain) { - useSyncConfigStore().setSimplePrefAndSave({ - path: 'onBlockDefaultAction', + this.$store.dispatch('setOption', { + name: 'onBlockDefaultAction', value: this.expiryString, }) } diff --git a/src/lib/language.js b/src/lib/language.js index beabfcca8..68e3a0989 100644 --- a/src/lib/language.js +++ b/src/lib/language.js @@ -15,7 +15,8 @@ export const piniaLanguagePlugin = ({ store, options }) => { if (name === 'setPreference') { const { path, value } = args[0] if (path === 'simple.interfaceLanguage') { - messages.setLanguage(useI18nStore().i18n, value) + useI18nStore().setLanguage(value) + messages.setLanguage(this.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 334b51c2b..bf6a5cd7b 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.setSimplePrefAndSave({ path: field, value: rootState.config[oldField ?? field] }) + serverside.setPreference({ path: 'simple.' + field, value: rootState.config[oldField ?? field] }) } } */ diff --git a/src/modules/notifications.js b/src/modules/notifications.js index ae6f71b70..9507177a2 100644 --- a/src/modules/notifications.js +++ b/src/modules/notifications.js @@ -118,7 +118,6 @@ 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 a8752feff..a22c157ed 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().unsetSimplePrefAndSave({ path: 'muteFilters.' + key, value: null }) + useSyncConfigStore().unsetPreference({ path: 'simple.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 e61186e7e..dfe788262 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({ - path: 'palettesIndex', + name: 'palettesIndex', value, }) return value } catch (e) { console.error('Could not fetch palettes index', e) useInstanceStore().set({ - path: 'palettesIndex', + name: 'palettesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -243,8 +243,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - useSyncConfigStore().setPreference({ path: 'simple.palette', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'palette', value }) this.applyTheme({ recompile: true }) }, @@ -252,8 +251,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'paletteCustomData', value }) this.applyTheme({ recompile: true }) }, @@ -263,12 +261,12 @@ export const useInterfaceStore = defineStore('interface', { '/static/styles/index.json', deserialize, ) - useInstanceStore().set({ path: 'stylesIndex', value }) + useInstanceStore().set({ name: 'stylesIndex', value }) return value } catch (e) { console.error('Could not fetch styles index', e) useInstanceStore().set({ - path: 'simple.stylesIndex', + name: 'stylesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -279,8 +277,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() this.resetThemeV3Palette() - useSyncConfigStore().setPreference({ path: 'simple.style', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'style', value }) this.useStylePalette = true this.applyTheme({ recompile: true }).then(() => { @@ -292,8 +289,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() this.resetThemeV3Palette() - useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'styleCustomData', value }) this.useStylePalette = true this.applyTheme({ recompile: true }).then(() => { @@ -303,12 +299,12 @@ export const useInterfaceStore = defineStore('interface', { async fetchThemesIndex() { try { const value = await getResourcesIndex('/static/styles.json') - useInstanceStore().set({ path: 'simple.themesIndex', value }) + useInstanceStore().set({ name: 'themesIndex', value }) return value } catch (e) { console.error('Could not fetch themes index', e) useInstanceStore().set({ - path: 'themesIndex', + name: 'themesIndex', value: { _error: e }, }) return Promise.resolve({}) @@ -319,8 +315,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - useSyncConfigStore().setPreference({ path: 'simple.theme', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'theme', value }) this.applyTheme({ recompile: true }) }, @@ -329,33 +324,29 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - useSyncConfigStore().setPreference({ path: 'simple.customTheme', value }) - useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'customTheme', value }) + window.vuex.commit('setOption', { name: 'customThemeSource', value }) this.applyTheme({ recompile: true }) }, resetThemeV3() { - useSyncConfigStore().setPreference({ path: 'simple.style', value: null }) - useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null }) - useSyncConfigStore().pushSyncConfig() + window.vuex.commit('setOption', { name: 'style', value: null }) + window.vuex.commit('setOption', { name: 'styleCustomData', value: null }) }, resetThemeV3Palette() { - useSyncConfigStore().setPreference({ path: 'simple.palette', value: null }) - useSyncConfigStore().setPreference({ - path: 'simple.paletteCustomData', + window.vuex.commit('setOption', { name: 'palette', value: null }) + window.vuex.commit('setOption', { + name: 'paletteCustomData', value: null, }) - useSyncConfigStore().pushSyncConfig() }, resetThemeV2() { - useSyncConfigStore().setPreference({ path: 'simple.theme', value: null }) - useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null }) - useSyncConfigStore().setPreference({ - path: 'simple.customThemeSource', + window.vuex.commit('setOption', { name: 'theme', value: null }) + window.vuex.commit('setOption', { name: 'customTheme', value: null }) + window.vuex.commit('setOption', { + name: 'customThemeSource', value: null, }) - useSyncConfigStore().pushSyncConfig() }, async getThemeData() { const getData = async (resource, index, customData, name) => { @@ -521,11 +512,10 @@ export const useInterfaceStore = defineStore('interface', { ) if (this.useStylePalette) { - useSyncConfigStore().setPreference({ - path: 'simple.palette', + window.vuex.commit('setOption', { + name: 'palette', value: firstStylePaletteName, }) - useSyncConfigStore().pushSyncConfig() } this.paletteNameUsed = palette.nameUsed diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 91394139f..009ccbce4 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -417,14 +417,6 @@ 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( @@ -480,7 +472,7 @@ export const useSyncConfigStore = defineStore('sync_config', { `Calling unset on depth > 3 (path: ${path}) is not allowed`, ) } - unset(this.prefsStorage, path) + unset(this.prefsStorage, path, value) this.prefsStorage._journal = [ ...this.prefsStorage._journal, { operation: 'unset', path, args: [], timestamp: Date.now() },