diff --git a/src/App.js b/src/App.js index 44ff6aee3..5b1403828 100644 --- a/src/App.js +++ b/src/App.js @@ -26,8 +26,8 @@ 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 { useMergedConfigStore } from 'src/stores/merged_config.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' @@ -80,7 +80,7 @@ export default { }, created() { // Load the locale from the storage - const value = useMergedConfigStore().mergedConfig.interfaceLanguage + const value = useSyncConfigStore().mergedConfig.interfaceLanguage useI18nStore().setLanguage(value) useEmojiStore().loadUnicodeEmojiData(value) @@ -132,7 +132,7 @@ export default { ] }, navClasses() { - const { navbarColumnStretch } = useMergedConfigStore().mergedConfig + const { navbarColumnStretch } = useSyncConfigStore().mergedConfig return [ '-' + this.layoutType, ...(navbarColumnStretch ? ['-column-stretch'] : []), @@ -145,7 +145,7 @@ export default { return this.currentUser.background_image }, instanceBackground() { - return useMergedConfigStore().mergedConfig.hideInstanceWallpaper + return useSyncConfigStore().mergedConfig.hideInstanceWallpaper ? null : this.instanceBackgroundUrl }, @@ -172,21 +172,19 @@ export default { if (this.isChats) return false if (this.isListEdit) return false return ( - useMergedConfigStore().mergedConfig.alwaysShowNewPostButton || + useSyncConfigStore().mergedConfig.alwaysShowNewPostButton || this.layoutType === 'mobile' ) }, shoutboxPosition() { - return ( - useMergedConfigStore().mergedConfig.alwaysShowNewPostButton || false - ) + return useSyncConfigStore().mergedConfig.alwaysShowNewPostButton || false }, hideShoutbox() { - return useMergedConfigStore().mergedConfig.hideShoutbox + return useSyncConfigStore().mergedConfig.hideShoutbox }, reverseLayout() { const { thirdColumnMode, sidebarRight: reverseSetting } = - useMergedConfigStore().mergedConfig + useSyncConfigStore().mergedConfig if (this.layoutType !== 'wide') { return reverseSetting } else { @@ -196,10 +194,10 @@ export default { } }, noSticky() { - return useMergedConfigStore().mergedConfig.disableStickyHeaders + return useSyncConfigStore().mergedConfig.disableStickyHeaders }, showScrollbars() { - return useMergedConfigStore().mergedConfig.showScrollbars + return useSyncConfigStore().mergedConfig.showScrollbars }, scrollParent() { return window /* this.$refs.appContentRef */ @@ -207,10 +205,10 @@ export default { showInstanceSpecificPanel() { return ( this.instanceSpecificPanelPresent && - !useMergedConfigStore().mergedConfig.hideISP + !useSyncConfigStore().mergedConfig.hideISP ) }, - ...mapState(useMergedConfigStore, ['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), ...mapState(useInterfaceStore, [ 'themeApplied', 'styleDataUsed', diff --git a/src/boot/after_store.js b/src/boot/after_store.js index a345e2ae5..5c2aaa6ef 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -33,15 +33,14 @@ 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 { useMergedConfigStore } from 'src/stores/merged_config.js' import { useOAuthStore } from 'src/stores/oauth' import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useUserHighlightStore } from 'src/stores/user_highlight.js' import VBodyScrollLock from 'src/directives/body_scroll_lock' import { - INSTANCE_DEFAULT_CONFIG_DEFINITIONS, - INSTANCE_IDENTITY_DEFAULT_DEFINITIONS, + instanceDefaultConfigDefinitions, + instanceIdentityDefaultDefinitions, } from 'src/modules/default_config_state.js' let staticInitialResults = null @@ -84,7 +83,7 @@ const getInstanceConfig = async ({ store }) => { const res = await preloadFetch('/api/v1/instance') if (res.ok) { const data = await res.json() - const textLimit = data.max_toot_chars + const textlimit = data.max_toot_chars const vapidPublicKey = data.pleroma.vapid_public_key useInstanceCapabilitiesStore().set( @@ -92,8 +91,8 @@ const getInstanceConfig = async ({ store }) => { data.pleroma, ) useInstanceStore().set({ - path: 'limits.textLimit', - value: textLimit, + path: 'textlimit', + value: textlimit, }) useInstanceStore().set({ path: 'accountApprovalRequired', @@ -170,19 +169,22 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { config = Object.assign({}, staticConfig, apiConfig) } - Object.keys(INSTANCE_IDENTITY_DEFAULT_DEFINITIONS).forEach((source) => - useInstanceStore().set({ - value: config[source], - path: `instanceIdentity.${source}`, - }), - ) + const copyInstanceOption = ({ source, definition = { required: true }, destination }) => { + const value = config[source] + let { required, type, default: defaultValue } = definition + if (type == null && defaultValue != null) type = typeof defaultValue + if (required && value == null) return + if (type != null && typeof value !== type) return - Object.keys(INSTANCE_DEFAULT_CONFIG_DEFINITIONS).forEach((source) => - useInstanceStore().set({ - value: config[source], - path: `prefsStorage.${source}`, - }), - ) + useInstanceStore().set({ path: destination, value }) + } + + Object.entries(instanceIdentityDefaultDefinitions) + .map(([source, definition]) => ({ source, definition, destination: `instanceIdentity.${source}` })) + .forEach(copyInstanceOption) + Object.keys(instanceDefaultConfigDefinitions) + .map(([source, definition]) => ({ source, definition, destination: `prefsStorage.${source}` })) + .forEach(copyInstanceOption) useAuthFlowStore().setInitialStrategy(config.loginMethod) } @@ -192,7 +194,7 @@ const getTOS = async ({ store }) => { const res = await window.fetch('/static/terms-of-service.html') if (res.ok) { const html = await res.text() - useInstanceStore().set({ path: 'instanceIdentity.tos', value: html }) + useInstanceStore().set({ name: 'instanceIdentity.tos', value: html }) } else { throw res } @@ -528,7 +530,6 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { useInterfaceStore().setLayoutWidth(windowWidth()) useInterfaceStore().setLayoutHeight(windowHeight()) window.syncConfig = useSyncConfigStore() - window.mergedConfig = useMergedConfigStore() window.localConfig = useLocalConfigStore() window.highlightConfig = useUserHighlightStore() @@ -542,7 +543,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { typeof overrides.target !== 'undefined' ? overrides.target : window.location.origin - useInstanceStore().set({ path: 'server', value: server }) + useInstanceStore().set({ name: 'server', value: server }) await setConfig({ store }) try { @@ -556,7 +557,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { return Promise.reject(e) } - applyStyleConfig(useMergedConfigStore().mergedConfig, i18n.global) + applyStyleConfig(useSyncConfigStore().mergedConfig, i18n.global) // Now we can try getting the server settings and logging in // Most of these are preloaded into the index.html so blocking is minimized diff --git a/src/components/about/about.js b/src/components/about/about.js index 404843e8b..ab1ace320 100644 --- a/src/components/about/about.js +++ b/src/components/about/about.js @@ -5,7 +5,7 @@ import StaffPanel from '../staff_panel/staff_panel.vue' import TermsOfServicePanel from '../terms_of_service_panel/terms_of_service_panel.vue' import { useInstanceStore } from 'src/stores/instance.js' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' const About = { components: { @@ -22,7 +22,7 @@ const About = { showInstanceSpecificPanel() { return ( useInstanceStore().instanceIdentity.showInstanceSpecificPanel && - !useMergedConfigStore().mergedConfig.hideISP && + !useSyncConfigStore().mergedConfig.hideISP && useInstanceStore().instanceIdentity.instanceSpecificPanelContent ) }, diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index f204adbde..38f585675 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -7,8 +7,8 @@ import Popover from '../popover/popover.vue' import ProgressButton from '../progress_button/progress_button.vue' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' -import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useReportsStore } from 'src/stores/reports' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faEllipsisV } from '@fortawesome/free-solid-svg-icons' @@ -90,10 +90,10 @@ const AccountActions = { }, computed: { shouldConfirmBlock() { - return useMergedConfigStore().mergedConfig.modalOnBlock + return useSyncConfigStore().mergedConfig.modalOnBlock }, shouldConfirmRemoveUserFromFollowers() { - return useMergedConfigStore().mergedConfig.modalOnRemoveUserFromFollowers + return useSyncConfigStore().mergedConfig.modalOnRemoveUserFromFollowers }, ...mapState(useInstanceCapabilitiesStore, [ 'blockExpiration', diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index fbe77a687..32d8426b8 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -8,7 +8,7 @@ import VideoAttachment from '../video_attachment/video_attachment.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useMediaViewerStore } from 'src/stores/media_viewer' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -58,8 +58,8 @@ const Attachment = { localDescription: this.description || this.attachment.description, nsfwImage: useInstanceStore().instanceIdentity.nsfwCensorImage || nsfwImage, - hideNsfwLocal: useMergedConfigStore().mergedConfig.hideNsfw, - preloadImage: useMergedConfigStore().mergedConfig.preloadImage, + hideNsfwLocal: useSyncConfigStore().mergedConfig.hideNsfw, + preloadImage: useSyncConfigStore().mergedConfig.preloadImage, loading: false, img: this.attachment.type === 'image' && document.createElement('img'), modalOpen: false, @@ -91,7 +91,7 @@ const Attachment = { return this.size === 'hide' }, useContainFit() { - return this.mergedConfig.useContainFit + return useSyncConfigStore().mergedConfig.useContainFit }, placeholderName() { if (this.attachment.description === '' || !this.attachment.description) { @@ -134,7 +134,7 @@ const Attachment = { videoTag() { return this.useModal ? 'button' : 'span' }, - ...mapState(useMergedConfigStore, ['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 1675f9ddd..b7267be2b 100644 --- a/src/components/chat_message/chat_message.js +++ b/src/components/chat_message/chat_message.js @@ -12,7 +12,7 @@ import UserAvatar from '../user_avatar/user_avatar.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useInterfaceStore } from 'src/stores/interface' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +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 +86,7 @@ const ChatMessage = { return { left: 50 } } }, - ...mapPiniaState(useMergedConfigStore, ['mergedConfig', 'findUser']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig', 'findUser']), }, data() { return { diff --git a/src/components/confirm_modal/mute_confirm.js b/src/components/confirm_modal/mute_confirm.js index ffd3a3076..888aa017b 100644 --- a/src/components/confirm_modal/mute_confirm.js +++ b/src/components/confirm_modal/mute_confirm.js @@ -3,7 +3,7 @@ import { mapState } from 'pinia' import Select from 'src/components/select/select.vue' import ConfirmModal from './confirm_modal.vue' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' export default { props: ['type', 'user', 'status'], @@ -45,7 +45,7 @@ export default { } } }, - ...mapState(useMergedConfigStore, ['mergedConfig']), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, methods: { optionallyPrompt() { diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index b0d3a304c..c3bd50444 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -9,7 +9,7 @@ import Status from '../status/status.vue' import ThreadTree from '../thread_tree/thread_tree.vue' import { useInterfaceStore } from 'src/stores/interface' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -82,7 +82,7 @@ const conversation = { // maxDepthInThread = max number of depths that is *visible* // since our depth starts with 0 and "showing" means "showing children" // there is a -2 here - const maxDepth = this.mergedConfig.maxDepthInThread - 2 + const maxDepth = useSyncConfigStore().mergedConfig.maxDepthInThread - 2 return maxDepth >= 1 ? maxDepth : 1 }, streamingEnabled() { @@ -92,22 +92,22 @@ const conversation = { ) }, displayStyle() { - return this.mergedConfig.conversationDisplay + return useSyncConfigStore().mergedConfig.conversationDisplay }, isTreeView() { return !this.isLinearView }, treeViewIsSimple() { - return !this.mergedConfig.conversationTreeAdvanced + return !useSyncConfigStore().mergedConfig.conversationTreeAdvanced }, isLinearView() { return this.displayStyle === 'linear' }, shouldFadeAncestors() { - return this.mergedConfig.conversationTreeFadeAncestors + return useSyncConfigStore().mergedConfig.conversationTreeFadeAncestors }, otherRepliesButtonPosition() { - return this.mergedConfig.conversationOtherRepliesButton + return useSyncConfigStore().mergedConfig.conversationOtherRepliesButton }, showOtherRepliesButtonBelowStatus() { return this.otherRepliesButtonPosition === 'below' @@ -393,7 +393,7 @@ const conversation = { maybeHighlight() { return this.isExpanded ? this.highlight : null }, - ...mapPiniaState(useMergedConfigStore, ['mergedConfig']), + ...mapPiniaState(useSyncConfigStore, ['mergedConfig']), ...mapState({ mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus, }), diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index 3382413a0..0871e0bd3 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -5,7 +5,7 @@ import ConfirmModal from '../confirm_modal/confirm_modal.vue' import { useInstanceStore } from 'src/stores/instance.js' import { useInterfaceStore } from 'src/stores/interface' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -97,7 +97,7 @@ export default { return this.$store.state.users.currentUser }, shouldConfirmLogout() { - return useMergedConfigStore().mergedConfig.modalOnLogout + return useSyncConfigStore().mergedConfig.modalOnLogout }, }, methods: { diff --git a/src/components/dialog_modal/dialog_modal.js b/src/components/dialog_modal/dialog_modal.js index 083f7a21d..e5c399086 100644 --- a/src/components/dialog_modal/dialog_modal.js +++ b/src/components/dialog_modal/dialog_modal.js @@ -1,4 +1,4 @@ -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' const DialogModal = { props: { @@ -15,7 +15,7 @@ const DialogModal = { }, computed: { mobileCenter() { - return useMergedConfigStore().mergedConfig.modalMobileCenter + return useSyncConfigStore().mergedConfig.modalMobileCenter }, }, } diff --git a/src/components/draft/draft.js b/src/components/draft/draft.js index ffc299af6..5ee85dff4 100644 --- a/src/components/draft/draft.js +++ b/src/components/draft/draft.js @@ -6,7 +6,7 @@ import Gallery from 'src/components/gallery/gallery.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' import StatusContent from 'src/components/status_content/status_content.vue' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faPollH } from '@fortawesome/free-solid-svg-icons' @@ -59,7 +59,7 @@ const Draft = { : undefined }, localCollapseSubjectDefault() { - return useMergedConfigStore().mergedConfig.collapseMessageWithSubject + return useSyncConfigStore().mergedConfig.collapseMessageWithSubject }, nsfwClickthrough() { if (!this.draft.nsfw) { diff --git a/src/components/draft_closer/draft_closer.js b/src/components/draft_closer/draft_closer.js index 2648b40c5..5f297bf4c 100644 --- a/src/components/draft_closer/draft_closer.js +++ b/src/components/draft_closer/draft_closer.js @@ -1,6 +1,6 @@ import DialogModal from 'src/components/dialog_modal/dialog_modal.vue' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' const DraftCloser = { data() { @@ -14,10 +14,10 @@ const DraftCloser = { emits: ['save', 'discard'], computed: { action() { - if (useMergedConfigStore().mergedConfig.autoSaveDraft) { + if (useSyncConfigStore().mergedConfig.autoSaveDraft) { return 'save' } else { - return useMergedConfigStore().mergedConfig.unsavedPostAction + return useSyncConfigStore().mergedConfig.unsavedPostAction } }, shouldConfirm() { diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js index 0146a3de8..ae46b0334 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -9,7 +9,7 @@ import genRandomSeed from '../../services/random_seed/random_seed.service.js' import EmojiPicker from '../emoji_picker/emoji_picker.vue' import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faSmileBeam } from '@fortawesome/free-regular-svg-icons' @@ -133,10 +133,10 @@ const EmojiInput = { }, computed: { padEmoji() { - return useMergedConfigStore().mergedConfig.padEmoji + return useSyncConfigStore().mergedConfig.padEmoji }, defaultCandidateIndex() { - return useMergedConfigStore().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( - useMergedConfigStore().mergedConfig.interfaceLanguage, + useSyncConfigStore().mergedConfig.interfaceLanguage, ) }, maybeLocalizedEmojiNamesAndKeywords() { diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js index 1d19987ac..1e4594b2c 100644 --- a/src/components/emoji_picker/emoji_picker.js +++ b/src/components/emoji_picker/emoji_picker.js @@ -8,7 +8,7 @@ import StillImage from '../still-image/still-image.vue' import { useEmojiStore } from 'src/stores/emoji.js' import { useInstanceStore } from 'src/stores/instance.js' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -341,7 +341,7 @@ const EmojiPicker = { this.$nextTick(() => { this.updateEmojiSize() }) - return useMergedConfigStore().mergedConfig.fontSize + return useSyncConfigStore().mergedConfig.fontSize }, emojiHeight() { return this.emojiSize @@ -406,7 +406,7 @@ const EmojiPicker = { }, languages() { return ensureFinalFallback( - useMergedConfigStore().mergedConfig.interfaceLanguage, + useSyncConfigStore().mergedConfig.interfaceLanguage, ) }, maybeLocalizedEmojiName() { diff --git a/src/components/extra_notifications/extra_notifications.js b/src/components/extra_notifications/extra_notifications.js index ec5ceebe1..e00f58bec 100644 --- a/src/components/extra_notifications/extra_notifications.js +++ b/src/components/extra_notifications/extra_notifications.js @@ -3,7 +3,7 @@ import { mapGetters } from 'vuex' import { useAnnouncementsStore } from 'src/stores/announcements.js' import { useInterfaceStore } from 'src/stores/interface.js' -import { useMergedConfigStore } from 'src/stores/merged_config.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -52,11 +52,10 @@ const ExtraNotifications = { currentUser() { return this.$store.state.users.currentUser }, - ...mapGetters(['unreadChatCount', 'followRequestCount']), + ...mapGetters(['unreadChatCount', 'followRequestCount', 'mergedConfig']), ...mapPiniaState(useAnnouncementsStore, { unreadAnnouncementCount: 'unreadAnnouncementCount', }), - ...mapPiniaState(useMergedConfigStore, ['mergedConfig']), }, methods: { openNotificationSettings() { diff --git a/src/components/features_panel/features_panel.js b/src/components/features_panel/features_panel.js index 10deda250..106da1487 100644 --- a/src/components/features_panel/features_panel.js +++ b/src/components/features_panel/features_panel.js @@ -15,7 +15,7 @@ const FeaturesPanel = { 'mediaProxyAvailable', ]), ...mapState(useInstanceStore, { - textLimit: (store) => store.limits.textLimit, + textlimit: (store) => store.limits.textlimit, uploadlimit: (store) => fileSizeFormatService.fileSizeFormat(store.limits.uploadlimit), }), diff --git a/src/components/features_panel/features_panel.vue b/src/components/features_panel/features_panel.vue index f15ad0edb..4270436fa 100644 --- a/src/components/features_panel/features_panel.vue +++ b/src/components/features_panel/features_panel.vue @@ -24,7 +24,7 @@ {{ $t('features_panel.media_proxy') }}