diff --git a/src/App.js b/src/App.js index 4fcfaf2c6..65302f54a 100644 --- a/src/App.js +++ b/src/App.js @@ -1,6 +1,9 @@ import { throttle } from 'lodash' import { mapState } from 'pinia' import { defineAsyncComponent } from 'vue' +import { mapGetters } from 'vuex' +import messages from 'src/i18n/messages' +import localeService from 'src/services/locale/locale.service.js' import DesktopNav from './components/desktop_nav/desktop_nav.vue' import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue' @@ -21,17 +24,14 @@ import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_pan import { getOrCreateServiceWorker } from './services/sw/sw' import { windowHeight, windowWidth } from './services/window_utils/window_utils' -import { useEmojiStore } from 'src/stores/emoji.js' import { useI18nStore } from 'src/stores/i18n.js' +import { useEmojiStore } from 'src/stores/emoji.js' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInterfaceStore } from 'src/stores/interface.js' import { useShoutStore } from 'src/stores/shout.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' -import messages from 'src/i18n/messages' -import localeService from 'src/services/locale/locale.service.js' - export default { name: 'app', components: { @@ -142,9 +142,7 @@ export default { return this.currentUser.background_image }, instanceBackground() { - return useSyncConfigStore().mergedConfig.hideInstanceWallpaper - ? null - : this.instanceBackgroundUrl + return useSyncConfigStore().mergedConfig.hideInstanceWallpaper ? null : this.instanceBackgroundUrl }, background() { return this.userBackground || this.instanceBackground @@ -205,7 +203,7 @@ export default { !useSyncConfigStore().mergedConfig.hideISP ) }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState(useInterfaceStore, [ 'themeApplied', 'styleDataUsed', diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 2171ce900..b87ff8924 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -32,7 +32,6 @@ import { useI18nStore } from 'src/stores/i18n' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInterfaceStore } from 'src/stores/interface.js' -import { useLocalConfigStore } from 'src/stores/local_config.js' import { useOAuthStore } from 'src/stores/oauth' import { useSyncConfigStore } from 'src/stores/sync_config.js' @@ -524,8 +523,6 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { useInterfaceStore().setLayoutWidth(windowWidth()) useInterfaceStore().setLayoutHeight(windowHeight()) - window.syncConfig = useSyncConfigStore() - window.localConfig = useLocalConfigStore() FaviconService.initFaviconService() initServiceWorker(store) diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index e1f24c1fd..a67bd475e 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,4 @@ -import { mapState } from 'pinia' +import { mapGetters } from 'vuex' import nsfwImage from '../../assets/nsfw.png' import fileTypeService from '../../services/file_type/file_type.service.js' @@ -140,7 +140,7 @@ const Attachment = { videoTag() { return this.useModal ? 'button' : 'span' }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), }, watch: { 'attachment.description'(newVal) { diff --git a/src/components/chat_message/chat_message.js b/src/components/chat_message/chat_message.js index b7267be2b..af3701ebf 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -12,7 +12,6 @@ import UserAvatar from '../user_avatar/user_avatar.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useInterfaceStore } from 'src/stores/interface' -import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faEllipsisH, faTimes } from '@fortawesome/free-solid-svg-icons' @@ -86,7 +85,7 @@ const ChatMessage = { return { left: 50 } } }, - ...mapPiniaState(useSyncConfigStore, ['mergedConfig', 'findUser']), + ...mapGetters(['mergedConfig', 'findUser']), }, data() { return { diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index c3bd50444..76dd26352 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -1,6 +1,6 @@ import { clone, filter, findIndex, get, reduce } from 'lodash' import { mapState as mapPiniaState } from 'pinia' -import { mapState } from 'vuex' +import { mapGetters, mapState } from 'vuex' import { WSConnectionStatus } from '../../services/api/api.service.js' import QuickFilterSettings from '../quick_filter_settings/quick_filter_settings.vue' @@ -393,7 +393,7 @@ const conversation = { maybeHighlight() { return this.isExpanded ? this.highlight : null }, - ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState({ mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus, }), diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index ae46b0334..23de501de 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -136,7 +136,7 @@ const EmojiInput = { return useSyncConfigStore().mergedConfig.padEmoji }, defaultCandidateIndex() { - return useSyncConfigStore().mergedConfig.autocompleteSelect ? 0 : -1 + return this.$store.getters.mergedConfig.autocompleteSelect ? 0 : -1 }, preText() { return this.modelValue.slice(0, this.caret) @@ -165,7 +165,7 @@ const EmojiInput = { }, languages() { return ensureFinalFallback( - useSyncConfigStore().mergedConfig.interfaceLanguage, + this.$store.getters.mergedConfig.interfaceLanguage, ) }, maybeLocalizedEmojiNamesAndKeywords() { diff --git a/src/components/extra_notifications/extra_notifications.js b/src/components/extra_notifications/extra_notifications.js index e00f58bec..bfe8dbe42 100644 --- a/src/components/extra_notifications/extra_notifications.js +++ b/src/components/extra_notifications/extra_notifications.js @@ -3,7 +3,6 @@ import { mapGetters } from 'vuex' import { useAnnouncementsStore } from 'src/stores/announcements.js' import { useInterfaceStore } from 'src/stores/interface.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index ce537663f..37c30355c 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -1,4 +1,3 @@ -import { mapState as mapPiniaState } from 'pinia' import { defineAsyncComponent } from 'vue' import { mapGetters, mapState } from 'vuex' @@ -9,8 +8,6 @@ import { import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue' import UserAvatar from '../user_avatar/user_avatar.vue' -import { useSyncConfigStore } from 'src/stores/sync_config.js' - import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' import { library } from '@fortawesome/fontawesome-svg-core' @@ -159,7 +156,7 @@ const MentionLink = { shouldFadeDomain() { return this.mergedConfig.mentionLinkFadeDomain }, - ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState({ currentUser: (state) => state.users.currentUser, }), diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 73b057eac..df2792c80 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -412,7 +412,7 @@ const PostStatusForm = { ) ) }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState(useInterfaceStore, { mobileLayout: (store) => store.mobileLayout, }), diff --git a/src/components/quick_filter_settings/quick_filter_settings.js b/src/components/quick_filter_settings/quick_filter_settings.js index feaa1c3ca..6dc2b57af 100644 --- a/src/components/quick_filter_settings/quick_filter_settings.js +++ b/src/components/quick_filter_settings/quick_filter_settings.js @@ -1,9 +1,9 @@ import { mapState } from 'pinia' +import { mapGetters } from 'vuex' import Popover from '../popover/popover.vue' import { useInterfaceStore } from 'src/stores/interface.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons' @@ -31,7 +31,7 @@ const QuickFilterSettings = { }, }, computed: { - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState(useInterfaceStore, { mobileLayout: (state) => state.layoutType === 'mobile', }), @@ -87,10 +87,7 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMedia - useSyncConfigStore().setSimplePrefAndSave({ - path: 'hideAttachments', - value, - }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value }) useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachmentsInConv', value, @@ -115,10 +112,7 @@ const QuickFilterSettings = { }, set() { const value = !this.muteBotStatuses - useSyncConfigStore().setSimplePrefAndSave({ - path: 'muteBotStatuses', - value, - }) + useSyncConfigStore().setSimplePrefAndSave({ path: 'muteBotStatuses', value }) }, }, muteSensitiveStatuses: { diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index cb9bb0466..f93e3eb59 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -259,10 +259,7 @@ export default { const writePath = `simple.${readPath}` if (!this.timedApplyMode) { - useSyncConfigStore().setSimplePrefAndSave({ - path: writePath, - value, - }) + useSyncConfigStore().setSimplePrefAndSave({ path: writePath, value }) useSyncConfigStore().pushSyncConfig() } else { if (useInterfaceStore().temporaryChangesTimeoutId !== null) { diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js index 7910744c7..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' diff --git a/src/components/settings_modal/tabs/posts_tab.js b/src/components/settings_modal/tabs/posts_tab.js index d81e67b51..bf0b8d200 100644 --- a/src/components/settings_modal/tabs/posts_tab.js +++ b/src/components/settings_modal/tabs/posts_tab.js @@ -5,8 +5,6 @@ import IntegerSetting from '../helpers/integer_setting.vue' import ProfileSettingIndicator from '../helpers/profile_setting_indicator.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' - const GeneralTab = { data() { return { diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index bc8f9226d..a906cd3ba 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -10,8 +10,8 @@ import { useAnnouncementsStore } from 'src/stores/announcements' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInterfaceStore } from 'src/stores/interface' -import { useShoutStore } from 'src/stores/shout' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { useShoutStore } from 'src/stores/shout' import { library } from '@fortawesome/fontawesome-svg-core' import { diff --git a/src/components/status_action_buttons/buttons_definitions.js b/src/components/status_action_buttons/buttons_definitions.js index 5a44e1ca5..20db7aa45 100644 --- a/src/components/status_action_buttons/buttons_definitions.js +++ b/src/components/status_action_buttons/buttons_definitions.js @@ -3,7 +3,6 @@ import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useReportsStore } from 'src/stores/reports.js' import { useStatusHistoryStore } from 'src/stores/statusHistory.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' const PRIVATE_SCOPES = new Set(['private', 'direct']) const PUBLIC_SCOPES = new Set(['public', 'unlisted']) @@ -53,7 +52,7 @@ export const BUTTONS = [ !PRIVATE_SCOPES.has(status.visibility)), toggleable: true, confirm: ({ status, getters }) => - !status.repeated && useSyncConfigStore().mergedConfig.modalOnRepeat, + !status.repeated && getters.mergedConfig.modalOnRepeat, confirmStrings: { title: 'status.repeat_confirm_title', body: 'status.repeat_confirm', @@ -228,7 +227,7 @@ export const BUTTONS = [ currentUser.privileges.includes('messages_delete')) ) }, - confirm: ({ getters }) => useSyncConfigStore().mergedConfig.modalOnDelete, + confirm: ({ getters }) => getters.mergedConfig.modalOnDelete, confirmStrings: { title: 'status.delete_confirm_title', body: 'status.delete_confirm', diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index a8402a7ed..4a3872895 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -1,9 +1,7 @@ -import { mapState } from 'pinia' +import { mapGetters } from 'vuex' import RichContent from 'src/components/rich_content/rich_content.jsx' -import { useSyncConfigStore } from 'src/stores/sync_config.js' - import fileType from 'src/services/file_type/file_type.service' import { library } from '@fortawesome/fontawesome-svg-core' @@ -112,7 +110,7 @@ const StatusBody = { collapsedStatus() { return this.status.raw_html.replace(/(\n|)/g, ' ') }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), }, components: { RichContent, diff --git a/src/components/status_content/status_content.js b/src/components/status_content/status_content.js index 678005801..464005a62 100644 --- a/src/components/status_content/status_content.js +++ b/src/components/status_content/status_content.js @@ -1,4 +1,3 @@ -import { mapState as mapPiniaState } from 'pinia' import { mapGetters, mapState } from 'vuex' import StatusBody from 'src/components/status_body/status_body.vue' @@ -124,7 +123,7 @@ const StatusContent = { maxThumbnails() { return this.mergedConfig.maxThumbnails }, - ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), ...mapState({ currentUser: (state) => state.users.currentUser, }), diff --git a/src/components/timeago/timeago.js b/src/components/timeago/timeago.js index a9e874862..efb92d4cd 100644 --- a/src/components/timeago/timeago.js +++ b/src/components/timeago/timeago.js @@ -1,5 +1,3 @@ -import { useSyncConfigStore } from 'src/stores/sync_config.js' - import * as DateUtils from 'src/services/date_utils/date_utils.js' import localeService from 'src/services/locale/locale.service.js' @@ -15,17 +13,17 @@ export default { }, computed: { shouldUseAbsoluteTimeFormat() { - if (!useSyncConfigStore().mergedConfig.useAbsoluteTimeFormat) { + if (!this.$store.getters.mergedConfig.useAbsoluteTimeFormat) { return false } return ( DateUtils.durationStrToMs( - useSyncConfigStore().mergedConfig.absoluteTimeFormatMinAge, + this.$store.getters.mergedConfig.absoluteTimeFormatMinAge, ) <= this.relativeTimeMs ) }, time12hFormat() { - return useSyncConfigStore().mergedConfig.absoluteTimeFormat12h === '12h' + return this.$store.getters.mergedConfig.absoluteTimeFormat12h === '12h' }, browserLocale() { return localeService.internalToBrowserLocale(this.$i18n.locale) diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 3a1ede69c..b94a9ab9a 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -1,7 +1,7 @@ import isEqual from 'lodash/isEqual' import merge from 'lodash/merge' import ldUnescape from 'lodash/unescape' -import { mapState } from 'pinia' +import { mapGetters } from 'vuex' import Checkbox from 'src/components/checkbox/checkbox.vue' import ColorInput from 'src/components/color_input/color_input.vue' @@ -243,7 +243,7 @@ export default { }) } }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), }, userHighlightColor: { get() { @@ -391,7 +391,7 @@ export default { ], }) }, - ...mapState(useSyncConfigStore, ['mergedConfig']), + ...mapGetters(['mergedConfig']), }, methods: { muteUser() { diff --git a/src/modules/users.js b/src/modules/users.js index d3e6eae7c..a8752feff 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -682,6 +682,7 @@ const users = { useInterfaceStore().setLastTimeline('public-timeline') useInterfaceStore().setLayoutWidth(windowWidth()) useInterfaceStore().setLayoutHeight(windowHeight()) + //useSyncConfigStore().clearSyncConfig() }) }, loginUser(store, accessToken) { @@ -779,7 +780,7 @@ const users = { dispatch('startFetchingFollowRequests') } - if (useSyncConfigStore().mergedConfig.useStreamingApi) { + if (store.getters.mergedConfig.useStreamingApi) { dispatch('fetchTimeline', { timeline: 'friends', since: null }) dispatch('fetchNotifications', { since: null }) dispatch('enableMastoSockets', true) diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index fd3ef568c..73411b6a5 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -4,7 +4,6 @@ import { promiseInterval } from '../promise_interval/promise_interval.js' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInterfaceStore } from 'src/stores/interface.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' const update = ({ store, notifications, older }) => { store.dispatch('addNewNotifications', { notifications, older }) @@ -27,9 +26,10 @@ const mastoApiNotificationTypes = new Set([ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { const args = { credentials } + const { getters } = store const rootState = store.rootState || store.state const timelineData = rootState.notifications - const hideMutedPosts = useSyncConfigStore().mergedConfig.hideMutedPosts + const hideMutedPosts = getters.mergedConfig.hideMutedPosts if (useInstanceCapabilitiesStore().pleromaChatMessagesAvailable) { mastoApiNotificationTypes.add('pleroma:chat_mention') diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index b59653502..da62f8b37 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -6,7 +6,6 @@ import { promiseInterval } from '../promise_interval/promise_interval.js' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInterfaceStore } from 'src/stores/interface.js' -import { useSyncConfigStore } from 'src/stores/sync_config.js' const update = ({ store, @@ -45,8 +44,9 @@ const fetchAndUpdate = ({ }) => { const args = { timeline, credentials } const rootState = store.rootState || store.state + const { getters } = store const timelineData = rootState.statuses.timelines[camelCase(timeline)] - const { hideMutedPosts, replyVisibility } = useSyncConfigStore().mergedConfig + const { hideMutedPosts, replyVisibility } = getters.mergedConfig const loggedIn = !!rootState.users.currentUser if (older) { diff --git a/src/stores/i18n.js b/src/stores/i18n.js index 78706af17..f013f7c8f 100644 --- a/src/stores/i18n.js +++ b/src/stores/i18n.js @@ -1,8 +1,7 @@ import Cookies from 'js-cookie' -import { defineStore } from 'pinia' - import messages from 'src/i18n/messages' import localeService from 'src/services/locale/locale.service.js' +import { defineStore } from 'pinia' const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage' @@ -22,6 +21,6 @@ export const useI18nStore = defineStore('i18n', { BACKEND_LANGUAGE_COOKIE_NAME, localeService.internalToBackendLocaleMulti(value), ) - }, + } }, }) diff --git a/src/stores/interface.js b/src/stores/interface.js index 77982f927..e61186e7e 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -186,7 +186,7 @@ export const useInterfaceStore = defineStore('interface', { const mobileLayout = width <= 800 const normalOrMobile = mobileLayout ? 'mobile' : 'normal' - const { thirdColumnMode } = useSyncConfigStore().mergedConfig + const { thirdColumnMode } = window.vuex.getters.mergedConfig if (thirdColumnMode === 'none' || !window.vuex.state.users.currentUser) { this.layoutType = normalOrMobile } else { @@ -252,10 +252,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV3Palette() this.resetThemeV2() - useSyncConfigStore().setPreference({ - path: 'simple.paletteCustomData', - value, - }) + useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value }) useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) @@ -295,10 +292,7 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() this.resetThemeV3Palette() - useSyncConfigStore().setPreference({ - path: 'simple.styleCustomData', - value, - }) + useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value }) useSyncConfigStore().pushSyncConfig() this.useStylePalette = true @@ -336,27 +330,18 @@ export const useInterfaceStore = defineStore('interface', { this.resetThemeV2() useSyncConfigStore().setPreference({ path: 'simple.customTheme', value }) - useSyncConfigStore().setPreference({ - path: 'simple.customThemeSource', - value, - }) + useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value }) useSyncConfigStore().pushSyncConfig() this.applyTheme({ recompile: true }) }, resetThemeV3() { useSyncConfigStore().setPreference({ path: 'simple.style', value: null }) - useSyncConfigStore().setPreference({ - path: 'simple.styleCustomData', - value: null, - }) + useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null }) useSyncConfigStore().pushSyncConfig() }, resetThemeV3Palette() { - useSyncConfigStore().setPreference({ - path: 'simple.palette', - value: null, - }) + useSyncConfigStore().setPreference({ path: 'simple.palette', value: null }) useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value: null, @@ -365,10 +350,7 @@ export const useInterfaceStore = defineStore('interface', { }, resetThemeV2() { useSyncConfigStore().setPreference({ path: 'simple.theme', value: null }) - useSyncConfigStore().setPreference({ - path: 'simple.customTheme', - value: null, - }) + useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null }) useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value: null, diff --git a/src/stores/local_config.js b/src/stores/local_config.js deleted file mode 100644 index 208ae09cf..000000000 --- a/src/stores/local_config.js +++ /dev/null @@ -1,50 +0,0 @@ -import { cloneDeep, set } from 'lodash' -import { defineStore } from 'pinia' -import { toRaw } from 'vue' - -import { useInstanceStore } from 'src/stores/instance' - -import { defaultState as configDefaultState } from 'src/modules/default_config_state' - -export const defaultState = { - prefsStorage: { - ...configDefaultState, - }, -} - -export const useLocalConfigStore = defineStore('local_config', { - state() { - return cloneDeep(defaultState) - }, - actions: { - set({ path, value }) { - set(this.prefsStorage, path, value) - }, - unset({ path, value }) { - set(this.prefsStorage, path, undefined) - }, - clearSyncConfig() { - const blankState = { ...cloneDeep(defaultState) } - Object.keys(this).forEach((k) => { - this.prefsStorage[k] = blankState[k] - }) - }, - }, - getters: { - mergedConfig: (state) => { - const instancePrefs = useInstanceStore().prefsStorage - const result = Object.fromEntries( - Object.entries(state.prefsStorage).map(([k, v]) => [ - k, - v ?? instancePrefs[k], - ]), - ) - return result - }, - }, - persist: { - afterLoad(state) { - return state - }, - }, -}) diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 05a47fa64..99ff0f6d5 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -97,18 +97,14 @@ const _verifyPrefs = (state) => { if (typeof v === 'undefined') return if (typeof v === 'number' || typeof v === 'boolean') return if (typeof v === 'object') return - console.warn( - `Preference simple.${k} as invalid type ${typeof v}, reinitializing`, - ) + console.warn(`Preference simple.${k} as invalid type ${typeof v}, reinitializing`) set(state.prefsStorage.simple, k, defaultState.prefsStorage.simple[k]) }) // Collections Object.entries(defaultState.prefsStorage.collections).forEach(([k, v]) => { if (Array.isArray(v)) return - console.warn( - `Preference collections.${k} as invalid type ${typeof v}, reinitializing`, - ) + console.warn(`Preference collections.${k} as invalid type ${typeof v}, reinitializing`) set( state.prefsStorage.collections, k, @@ -310,9 +306,7 @@ export const _mergePrefs = (recent, stale) => { break case 'addToCollection': if (!path.startsWith('collections')) { - return console.error( - 'Illegal operation "addToCollection" on a non-collection', - ) + return console.error('Illegal operation "addToCollection" on a non-collection') } set( resultOutput, @@ -322,9 +316,7 @@ export const _mergePrefs = (recent, stale) => { break case 'removeFromCollection': { if (!path.startsWith('collections')) { - return console.error( - 'Illegal operation "removeFromCollection" on a non-collection', - ) + return console.error('Illegal operation "removeFromCollection" on a non-collection') } const newSet = new Set(get(resultOutput, path)) newSet.delete(args[0]) @@ -446,7 +438,9 @@ export const useSyncConfigStore = defineStore('sync_config', { `Tried to edit internal (starts with _) field '${path}', ignoring.`, ) } - if (path.startsWith('collections')) { + if ( + path.startsWith('collections') + ) { throw new Error( `Invalid operation 'set' for collection field '${path}', ignoring.`, ) @@ -474,7 +468,9 @@ export const useSyncConfigStore = defineStore('sync_config', { `Tried to edit internal (starts with _) field '${path}', ignoring.`, ) } - if (path.startsWith('collections')) { + if ( + path.startsWith('collections') + ) { throw new Error( `Invalid operation 'unset' for collection field '${path}', ignoring.`, )