From f77e1225b5c969259f6ae2cb4bb2c886116dffd8 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 23 Feb 2026 19:47:00 +0200 Subject: [PATCH 1/3] added config stores to global scope for easier debug --- src/boot/after_store.js | 3 +++ src/stores/local_config.js | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/stores/local_config.js diff --git a/src/boot/after_store.js b/src/boot/after_store.js index b87ff8924..a3f22560e 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -34,6 +34,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j import { useInterfaceStore } from 'src/stores/interface.js' import { useOAuthStore } from 'src/stores/oauth' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { useLocalConfigStore } from 'src/stores/local_config.js' import VBodyScrollLock from 'src/directives/body_scroll_lock' import { @@ -523,6 +524,8 @@ 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/stores/local_config.js b/src/stores/local_config.js new file mode 100644 index 000000000..78754f07b --- /dev/null +++ b/src/stores/local_config.js @@ -0,0 +1,53 @@ +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 + }, + }, +}) From 7738ce87e6fb7257f81d2c5535960d9c2c497177 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 23 Feb 2026 19:55:43 +0200 Subject: [PATCH 2/3] more getters migrated --- src/components/emoji_input/emoji_input.js | 4 ++-- src/components/mention_link/mention_link.js | 4 +++- .../status_action_buttons/buttons_definitions.js | 5 +++-- src/components/timeago/timeago.js | 8 +++++--- src/modules/users.js | 3 +-- .../notifications_fetcher.service.js | 3 ++- src/services/timeline_fetcher/timeline_fetcher.service.js | 3 ++- src/stores/interface.js | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index 23de501de..ae46b0334 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 this.$store.getters.mergedConfig.autocompleteSelect ? 0 : -1 + return useSyncConfigStore().mergedConfig.autocompleteSelect ? 0 : -1 }, preText() { return this.modelValue.slice(0, this.caret) @@ -165,7 +165,7 @@ const EmojiInput = { }, languages() { return ensureFinalFallback( - this.$store.getters.mergedConfig.interfaceLanguage, + useSyncConfigStore().mergedConfig.interfaceLanguage, ) }, maybeLocalizedEmojiNamesAndKeywords() { diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index 37c30355c..2f0b81b9e 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -1,5 +1,7 @@ import { defineAsyncComponent } from 'vue' import { mapGetters, mapState } from 'vuex' +import { mapState as mapPiniaState } from 'pinia' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { highlightClass, @@ -156,7 +158,7 @@ const MentionLink = { shouldFadeDomain() { return this.mergedConfig.mentionLinkFadeDomain }, - ...mapGetters(['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), ...mapState({ currentUser: (state) => state.users.currentUser, }), diff --git a/src/components/status_action_buttons/buttons_definitions.js b/src/components/status_action_buttons/buttons_definitions.js index 20db7aa45..4ac98bd21 100644 --- a/src/components/status_action_buttons/buttons_definitions.js +++ b/src/components/status_action_buttons/buttons_definitions.js @@ -1,5 +1,6 @@ import { useEditStatusStore } from 'src/stores/editStatus.js' import { useInstanceStore } from 'src/stores/instance.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useReportsStore } from 'src/stores/reports.js' import { useStatusHistoryStore } from 'src/stores/statusHistory.js' @@ -52,7 +53,7 @@ export const BUTTONS = [ !PRIVATE_SCOPES.has(status.visibility)), toggleable: true, confirm: ({ status, getters }) => - !status.repeated && getters.mergedConfig.modalOnRepeat, + !status.repeated && useSyncConfigStore().mergedConfig.modalOnRepeat, confirmStrings: { title: 'status.repeat_confirm_title', body: 'status.repeat_confirm', @@ -227,7 +228,7 @@ export const BUTTONS = [ currentUser.privileges.includes('messages_delete')) ) }, - confirm: ({ getters }) => getters.mergedConfig.modalOnDelete, + confirm: ({ getters }) => useSyncConfigStore().mergedConfig.modalOnDelete, confirmStrings: { title: 'status.delete_confirm_title', body: 'status.delete_confirm', diff --git a/src/components/timeago/timeago.js b/src/components/timeago/timeago.js index efb92d4cd..9dc440e46 100644 --- a/src/components/timeago/timeago.js +++ b/src/components/timeago/timeago.js @@ -1,6 +1,8 @@ import * as DateUtils from 'src/services/date_utils/date_utils.js' import localeService from 'src/services/locale/locale.service.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' + export default { name: 'Timeago', props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold', 'templateKey'], @@ -13,17 +15,17 @@ export default { }, computed: { shouldUseAbsoluteTimeFormat() { - if (!this.$store.getters.mergedConfig.useAbsoluteTimeFormat) { + if (!useSyncConfigStore().mergedConfig.useAbsoluteTimeFormat) { return false } return ( DateUtils.durationStrToMs( - this.$store.getters.mergedConfig.absoluteTimeFormatMinAge, + useSyncConfigStore().mergedConfig.absoluteTimeFormatMinAge, ) <= this.relativeTimeMs ) }, time12hFormat() { - return this.$store.getters.mergedConfig.absoluteTimeFormat12h === '12h' + return useSyncConfigStore().mergedConfig.absoluteTimeFormat12h === '12h' }, browserLocale() { return localeService.internalToBrowserLocale(this.$i18n.locale) diff --git a/src/modules/users.js b/src/modules/users.js index a8752feff..d3e6eae7c 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -682,7 +682,6 @@ const users = { useInterfaceStore().setLastTimeline('public-timeline') useInterfaceStore().setLayoutWidth(windowWidth()) useInterfaceStore().setLayoutHeight(windowHeight()) - //useSyncConfigStore().clearSyncConfig() }) }, loginUser(store, accessToken) { @@ -780,7 +779,7 @@ const users = { dispatch('startFetchingFollowRequests') } - if (store.getters.mergedConfig.useStreamingApi) { + if (useSyncConfigStore().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 73411b6a5..b9447276c 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -4,6 +4,7 @@ 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 }) @@ -29,7 +30,7 @@ const fetchAndUpdate = ({ store, credentials, older = false, since }) => { const { getters } = store const rootState = store.rootState || store.state const timelineData = rootState.notifications - const hideMutedPosts = getters.mergedConfig.hideMutedPosts + const hideMutedPosts = useSyncConfigStore().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 da62f8b37..90dff144a 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -6,6 +6,7 @@ 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, @@ -46,7 +47,7 @@ const fetchAndUpdate = ({ const rootState = store.rootState || store.state const { getters } = store const timelineData = rootState.statuses.timelines[camelCase(timeline)] - const { hideMutedPosts, replyVisibility } = getters.mergedConfig + const { hideMutedPosts, replyVisibility } = useSyncConfigStore().mergedConfig const loggedIn = !!rootState.users.currentUser if (older) { diff --git a/src/stores/interface.js b/src/stores/interface.js index e61186e7e..fc5fd36c8 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 } = window.vuex.getters.mergedConfig + const { thirdColumnMode } = useSyncConfigStore().mergedConfig if (thirdColumnMode === 'none' || !window.vuex.state.users.currentUser) { this.layoutType = normalOrMobile } else { From ca0da60bcd0884972ef62f970b6f0d425942ff41 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 23 Feb 2026 20:14:39 +0200 Subject: [PATCH 3/3] even more getter fixes --- src/App.js | 14 +++++---- src/boot/after_store.js | 2 +- src/components/attachment/attachment.js | 4 +-- src/components/chat_message/chat_message.js | 3 +- src/components/conversation/conversation.js | 4 +-- .../extra_notifications.js | 1 + src/components/mention_link/mention_link.js | 5 ++-- .../post_status_form/post_status_form.js | 2 +- .../quick_filter_settings.js | 14 ++++++--- .../settings_modal/helpers/setting.js | 5 +++- .../settings_modal/tabs/general_tab.js | 2 +- .../settings_modal/tabs/posts_tab.js | 2 ++ src/components/side_drawer/side_drawer.js | 2 +- .../buttons_definitions.js | 2 +- src/components/status_body/status_body.js | 6 ++-- .../status_content/status_content.js | 3 +- src/components/timeago/timeago.js | 4 +-- src/components/user_card/user_card.js | 6 ++-- .../notifications_fetcher.service.js | 1 - .../timeline_fetcher.service.js | 1 - src/stores/i18n.js | 5 ++-- src/stores/interface.js | 30 +++++++++++++++---- src/stores/local_config.js | 7 ++--- src/stores/sync_config.js | 24 ++++++++------- 24 files changed, 93 insertions(+), 56 deletions(-) diff --git a/src/App.js b/src/App.js index 65302f54a..4fcfaf2c6 100644 --- a/src/App.js +++ b/src/App.js @@ -1,9 +1,6 @@ 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' @@ -24,14 +21,17 @@ 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 { useI18nStore } from 'src/stores/i18n.js' import { useEmojiStore } from 'src/stores/emoji.js' +import { useI18nStore } from 'src/stores/i18n.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,7 +142,9 @@ 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 @@ -203,7 +205,7 @@ export default { !useSyncConfigStore().mergedConfig.hideISP ) }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), ...mapState(useInterfaceStore, [ 'themeApplied', 'styleDataUsed', diff --git a/src/boot/after_store.js b/src/boot/after_store.js index a3f22560e..2171ce900 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -32,9 +32,9 @@ 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' -import { useLocalConfigStore } from 'src/stores/local_config.js' import VBodyScrollLock from 'src/directives/body_scroll_lock' import { diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index a67bd475e..e1f24c1fd 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,4 @@ -import { mapGetters } from 'vuex' +import { mapState } from 'pinia' 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' }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, watch: { 'attachment.description'(newVal) { diff --git a/src/components/chat_message/chat_message.js b/src/components/chat_message/chat_message.js index af3701ebf..b7267be2b 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -12,6 +12,7 @@ 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' @@ -85,7 +86,7 @@ const ChatMessage = { return { left: 50 } } }, - ...mapGetters(['mergedConfig', 'findUser']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig', 'findUser']), }, data() { return { diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 76dd26352..c3bd50444 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 { mapGetters, mapState } from 'vuex' +import { 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 }, - ...mapGetters(['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), ...mapState({ mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus, }), diff --git a/src/components/extra_notifications/extra_notifications.js b/src/components/extra_notifications/extra_notifications.js index bfe8dbe42..e00f58bec 100644 --- a/src/components/extra_notifications/extra_notifications.js +++ b/src/components/extra_notifications/extra_notifications.js @@ -3,6 +3,7 @@ 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 2f0b81b9e..ce537663f 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -1,7 +1,6 @@ +import { mapState as mapPiniaState } from 'pinia' import { defineAsyncComponent } from 'vue' import { mapGetters, mapState } from 'vuex' -import { mapState as mapPiniaState } from 'pinia' -import { useSyncConfigStore } from 'src/stores/sync_config.js' import { highlightClass, @@ -10,6 +9,8 @@ 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' diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index df2792c80..73b057eac 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 = { ) ) }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['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 6dc2b57af..feaa1c3ca 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: { - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), ...mapState(useInterfaceStore, { mobileLayout: (state) => state.layoutType === 'mobile', }), @@ -87,7 +87,10 @@ const QuickFilterSettings = { }, set() { const value = !this.hideMedia - useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value }) + useSyncConfigStore().setSimplePrefAndSave({ + path: 'hideAttachments', + value, + }) useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachmentsInConv', value, @@ -112,7 +115,10 @@ 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 f93e3eb59..cb9bb0466 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -259,7 +259,10 @@ 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 4a618bd67..7910744c7 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' diff --git a/src/components/settings_modal/tabs/posts_tab.js b/src/components/settings_modal/tabs/posts_tab.js index bf0b8d200..d81e67b51 100644 --- a/src/components/settings_modal/tabs/posts_tab.js +++ b/src/components/settings_modal/tabs/posts_tab.js @@ -5,6 +5,8 @@ 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 a906cd3ba..bc8f9226d 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 { useSyncConfigStore } from 'src/stores/sync_config.js' import { useShoutStore } from 'src/stores/shout' +import { useSyncConfigStore } from 'src/stores/sync_config.js' 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 4ac98bd21..5a44e1ca5 100644 --- a/src/components/status_action_buttons/buttons_definitions.js +++ b/src/components/status_action_buttons/buttons_definitions.js @@ -1,9 +1,9 @@ import { useEditStatusStore } from 'src/stores/editStatus.js' import { useInstanceStore } from 'src/stores/instance.js' -import { useSyncConfigStore } from 'src/stores/sync_config.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']) diff --git a/src/components/status_body/status_body.js b/src/components/status_body/status_body.js index 4a3872895..a8402a7ed 100644 --- a/src/components/status_body/status_body.js +++ b/src/components/status_body/status_body.js @@ -1,7 +1,9 @@ -import { mapGetters } from 'vuex' +import { mapState } from 'pinia' 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' @@ -110,7 +112,7 @@ const StatusBody = { collapsedStatus() { return this.status.raw_html.replace(/(\n|)/g, ' ') }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, components: { RichContent, diff --git a/src/components/status_content/status_content.js b/src/components/status_content/status_content.js index 464005a62..678005801 100644 --- a/src/components/status_content/status_content.js +++ b/src/components/status_content/status_content.js @@ -1,3 +1,4 @@ +import { mapState as mapPiniaState } from 'pinia' import { mapGetters, mapState } from 'vuex' import StatusBody from 'src/components/status_body/status_body.vue' @@ -123,7 +124,7 @@ const StatusContent = { maxThumbnails() { return this.mergedConfig.maxThumbnails }, - ...mapGetters(['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), ...mapState({ currentUser: (state) => state.users.currentUser, }), diff --git a/src/components/timeago/timeago.js b/src/components/timeago/timeago.js index 9dc440e46..a9e874862 100644 --- a/src/components/timeago/timeago.js +++ b/src/components/timeago/timeago.js @@ -1,8 +1,8 @@ +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' -import { useSyncConfigStore } from 'src/stores/sync_config.js' - export default { name: 'Timeago', props: ['time', 'autoUpdate', 'longFormat', 'nowThreshold', 'templateKey'], diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index b94a9ab9a..3a1ede69c 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 { mapGetters } from 'vuex' +import { mapState } from 'pinia' import Checkbox from 'src/components/checkbox/checkbox.vue' import ColorInput from 'src/components/color_input/color_input.vue' @@ -243,7 +243,7 @@ export default { }) } }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, userHighlightColor: { get() { @@ -391,7 +391,7 @@ export default { ], }) }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, methods: { muteUser() { diff --git a/src/services/notifications_fetcher/notifications_fetcher.service.js b/src/services/notifications_fetcher/notifications_fetcher.service.js index b9447276c..fd3ef568c 100644 --- a/src/services/notifications_fetcher/notifications_fetcher.service.js +++ b/src/services/notifications_fetcher/notifications_fetcher.service.js @@ -27,7 +27,6 @@ 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 diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 90dff144a..b59653502 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -45,7 +45,6 @@ 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 loggedIn = !!rootState.users.currentUser diff --git a/src/stores/i18n.js b/src/stores/i18n.js index f013f7c8f..78706af17 100644 --- a/src/stores/i18n.js +++ b/src/stores/i18n.js @@ -1,7 +1,8 @@ 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' @@ -21,6 +22,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 fc5fd36c8..77982f927 100644 --- a/src/stores/interface.js +++ b/src/stores/interface.js @@ -252,7 +252,10 @@ 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 }) @@ -292,7 +295,10 @@ 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 @@ -330,18 +336,27 @@ 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, @@ -350,7 +365,10 @@ 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 index 78754f07b..208ae09cf 100644 --- a/src/stores/local_config.js +++ b/src/stores/local_config.js @@ -1,7 +1,4 @@ -import { - cloneDeep, - set, -} from 'lodash' +import { cloneDeep, set } from 'lodash' import { defineStore } from 'pinia' import { toRaw } from 'vue' @@ -12,7 +9,7 @@ import { defaultState as configDefaultState } from 'src/modules/default_config_s export const defaultState = { prefsStorage: { ...configDefaultState, - } + }, } export const useLocalConfigStore = defineStore('local_config', { diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 99ff0f6d5..05a47fa64 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -97,14 +97,18 @@ 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, @@ -306,7 +310,9 @@ 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, @@ -316,7 +322,9 @@ 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]) @@ -438,9 +446,7 @@ 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.`, ) @@ -468,9 +474,7 @@ 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.`, )