diff --git a/src/App.js b/src/App.js index bfdeb2be4..ae34d9d5e 100644 --- a/src/App.js +++ b/src/App.js @@ -3,7 +3,7 @@ import { mapState } from 'pinia' import { defineAsyncComponent } from 'vue' import { mapGetters } from 'vuex' -import { useServerSideStorageStore } from 'src/stores/serverSideStorage' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import DesktopNav from './components/desktop_nav/desktop_nav.vue' import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue' import FeaturesPanel from './components/features_panel/features_panel.vue' @@ -22,9 +22,9 @@ import UserReportingModal from './components/user_reporting_modal/user_reporting import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue' import { getOrCreateServiceWorker } from './services/sw/sw' import { windowHeight, windowWidth } from './services/window_utils/window_utils' -import { useInstanceStore } from './stores/instance' -import { useInterfaceStore } from './stores/interface' -import { useShoutStore } from './stores/shout' +import { useInstanceStore } from 'src/stores/instance.js' +import { useInterfaceStore } from 'src/stores/interface.js' +import { useShoutStore } from 'src/stores/shout.js' export default { name: 'app', @@ -70,9 +70,6 @@ export default { }, }, created() { - // Load the locale from the storage - const val = this.$store.getters.mergedConfig.interfaceLanguage - this.$store.dispatch('setOption', { name: 'interfaceLanguage', value: val }) document.getElementById('modal').classList = ['-' + this.layoutType] // Create bound handlers @@ -124,7 +121,7 @@ export default { ] }, navClasses() { - const { navbarColumnStretch } = this.$store.getters.mergedConfig + const { navbarColumnStretch } = useSyncConfigStore().mergedConfig return [ '-' + this.layoutType, ...(navbarColumnStretch ? ['-column-stretch'] : []), @@ -159,19 +156,19 @@ export default { if (this.isChats) return false if (this.isListEdit) return false return ( - this.$store.getters.mergedConfig.alwaysShowNewPostButton || + useSyncConfigStore().mergedConfig.alwaysShowNewPostButton || this.layoutType === 'mobile' ) }, shoutboxPosition() { - return this.$store.getters.mergedConfig.alwaysShowNewPostButton || false + return useSyncConfigStore().mergedConfig.alwaysShowNewPostButton || false }, layoutType() { return useInterfaceStore().layoutType }, reverseLayout() { const { thirdColumnMode, sidebarRight: reverseSetting } = - this.$store.getters.mergedConfig + useSyncConfigStore().mergedConfig if (this.layoutType !== 'wide') { return reverseSetting } else { @@ -181,16 +178,16 @@ export default { } }, noSticky() { - return this.$store.getters.mergedConfig.disableStickyHeaders + return useSyncConfigStore().mergedConfig.disableStickyHeaders }, showScrollbars() { - return this.$store.getters.mergedConfig.showScrollbars + return useSyncConfigStore().mergedConfig.showScrollbars }, scrollParent() { return window /* this.$refs.appContentRef */ }, ...mapGetters(['mergedConfig']), - ...mapState(useServerSideStorageStore, { + ...mapState(useSyncConfigStore, { hideShoutbox: (store) => store.mergedConfig.hideShoutbox, }), ...mapState(useInstanceStore, { @@ -198,7 +195,7 @@ export default { this.mergedConfig.hideInstanceWallpaper ? null : store.background, showInstanceSpecificPanel: (store) => store.showInstanceSpecificPanel && - !this.$store.getters.mergedConfig.hideISP && + !useSyncConfigStore().mergedConfig.hideISP && store.instanceSpecificPanelContent, }), ...mapState(useInstanceStore, [ diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 48dc42bc1..e89e3abcb 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -542,6 +542,7 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => { ? overrides.target : window.location.origin useInstanceStore().set({ path: 'server', value: server }) + console.log('AFTER', useInstanceStore().server, server) await setConfig({ store }) try { diff --git a/src/boot/routes.js b/src/boot/routes.js index 4077f67ba..0b8df95ac 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -28,12 +28,11 @@ import UserProfile from 'components/user_profile/user_profile.vue' import WhoToFollow from 'components/who_to_follow/who_to_follow.vue' import NavPanel from 'src/components/nav_panel/nav_panel.vue' +import { useInstanceStore } from 'src/stores/instance.js' import BookmarkFolderEdit from '../components/bookmark_folder_edit/bookmark_folder_edit.vue' import BookmarkFolders from '../components/bookmark_folders/bookmark_folders.vue' import QuotesTimeline from '../components/quotes_timeline/quotes_timeline.vue' -import { useInstanceStore } from 'src/stores/instance.js' - export default (store) => { const validateAuthenticatedRoute = (to, from, next) => { if (store.state.users.currentUser) { diff --git a/src/components/about/about.js b/src/components/about/about.js index d091dfd0a..4c1ec87d1 100644 --- a/src/components/about/about.js +++ b/src/components/about/about.js @@ -1,3 +1,5 @@ +import { useInstanceStore } from 'src/stores/instance.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import FeaturesPanel from '../features_panel/features_panel.vue' import InstanceSpecificPanel from '../instance_specific_panel/instance_specific_panel.vue' import MRFTransparencyPanel from '../mrf_transparency_panel/mrf_transparency_panel.vue' @@ -14,13 +16,13 @@ const About = { }, computed: { showFeaturesPanel() { - return this.$store.state.instance.showFeaturesPanel + return useInstanceStore().showFeaturesPanel }, showInstanceSpecificPanel() { return ( - this.$store.state.instance.showInstanceSpecificPanel && - !this.$store.getters.mergedConfig.hideISP && - this.$store.state.instance.instanceSpecificPanelContent + useInstanceStore().showInstanceSpecificPanel && + !useSyncConfigStore().mergedConfig.hideISP && + useInstanceStore().instanceSpecificPanelContent ) }, }, diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index ee94dc544..f9a1abf86 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -3,6 +3,7 @@ import { mapState } from 'vuex' import UserListMenu from 'src/components/user_list_menu/user_list_menu.vue' import UserTimedFilterModal from 'src/components/user_timed_filter_modal/user_timed_filter_modal.vue' import { useReportsStore } from 'src/stores/reports' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import ConfirmModal from '../confirm_modal/confirm_modal.vue' import Popover from '../popover/popover.vue' import ProgressButton from '../progress_button/progress_button.vue' @@ -87,10 +88,10 @@ const AccountActions = { }, computed: { shouldConfirmBlock() { - return this.$store.getters.mergedConfig.modalOnBlock + return useSyncConfigStore().mergedConfig.modalOnBlock }, shouldConfirmRemoveUserFromFollowers() { - return this.$store.getters.mergedConfig.modalOnRemoveUserFromFollowers + return useSyncConfigStore().mergedConfig.modalOnRemoveUserFromFollowers }, ...mapState({ blockExpirationSupported: (state) => state.instance.blockExpiration, diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 31fceba60..2b3211cb3 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,6 +1,8 @@ import { mapGetters } from 'vuex' +import { useInstanceStore } from 'src/stores/instance.js' import { useMediaViewerStore } from 'src/stores/media_viewer' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import nsfwImage from '../../assets/nsfw.png' import fileTypeService from '../../services/file_type/file_type.service.js' import Flash from '../flash/flash.vue' @@ -53,9 +55,9 @@ const Attachment = { data() { return { localDescription: this.description || this.attachment.description, - nsfwImage: this.$store.state.instance.nsfwCensorImage || nsfwImage, - hideNsfwLocal: this.$store.getters.mergedConfig.hideNsfw, - preloadImage: this.$store.getters.mergedConfig.preloadImage, + nsfwImage: useInstanceStore().nsfwCensorImage || nsfwImage, + hideNsfwLocal: useSyncConfigStore().mergedConfig.hideNsfw, + preloadImage: useSyncConfigStore().mergedConfig.preloadImage, loading: false, img: fileTypeService.fileType(this.attachment.mimetype) === 'image' && @@ -89,7 +91,7 @@ const Attachment = { return this.size === 'hide' }, useContainFit() { - return this.$store.getters.mergedConfig.useContainFit + return useSyncConfigStore().mergedConfig.useContainFit }, placeholderName() { if (this.attachment.description === '' || !this.attachment.description) { @@ -104,7 +106,7 @@ const Attachment = { return 'file' }, referrerpolicy() { - return this.$store.state.instance.mediaProxyAvailable ? '' : 'no-referrer' + return useInstanceStore().mediaProxyAvailable ? '' : 'no-referrer' }, type() { return fileTypeService.fileType(this.attachment.mimetype) diff --git a/src/components/avatar_list/avatar_list.js b/src/components/avatar_list/avatar_list.js index aad157686..938713207 100644 --- a/src/components/avatar_list/avatar_list.js +++ b/src/components/avatar_list/avatar_list.js @@ -1,4 +1,5 @@ import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { useInstanceStore } from 'src/stores/instance.js' import UserAvatar from '../user_avatar/user_avatar.vue' const AvatarList = { @@ -16,7 +17,7 @@ const AvatarList = { return generateProfileLink( user.id, user.screen_name, - this.$store.state.instance.restrictedNicknames, + useInstanceStore().restrictedNicknames, ) }, }, diff --git a/src/components/basic_user_card/basic_user_card.js b/src/components/basic_user_card/basic_user_card.js index cc4cbce44..8d2b17b7d 100644 --- a/src/components/basic_user_card/basic_user_card.js +++ b/src/components/basic_user_card/basic_user_card.js @@ -1,5 +1,6 @@ import RichContent from 'src/components/rich_content/rich_content.jsx' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { useInstanceStore } from 'src/stores/instance.js' import UserAvatar from '../user_avatar/user_avatar.vue' import UserLink from '../user_link/user_link.vue' import UserPopover from '../user_popover/user_popover.vue' @@ -17,7 +18,7 @@ const BasicUserCard = { return generateProfileLink( user.id, user.screen_name, - this.$store.state.instance.restrictedNicknames, + useInstanceStore().restrictedNicknames, ) }, }, diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 3caf4add7..fe654cba2 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -2,7 +2,9 @@ import { clone, filter, findIndex, get, reduce } from 'lodash' import { mapState as mapPiniaState } from 'pinia' import { mapGetters, mapState } from 'vuex' +import { useInstanceStore } from 'src/stores/instance.js' import { useInterfaceStore } from 'src/stores/interface' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { WSConnectionStatus } from '../../services/api/api.service.js' import QuickFilterSettings from '../quick_filter_settings/quick_filter_settings.vue' import QuickViewSettings from '../quick_view_settings/quick_view_settings.vue' @@ -80,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.$store.getters.mergedConfig.maxDepthInThread - 2 + const maxDepth = useSyncConfigStore().mergedConfig.maxDepthInThread - 2 return maxDepth >= 1 ? maxDepth : 1 }, streamingEnabled() { @@ -90,22 +92,22 @@ const conversation = { ) }, displayStyle() { - return this.$store.getters.mergedConfig.conversationDisplay + return useSyncConfigStore().mergedConfig.conversationDisplay }, isTreeView() { return !this.isLinearView }, treeViewIsSimple() { - return !this.$store.getters.mergedConfig.conversationTreeAdvanced + return !useSyncConfigStore().mergedConfig.conversationTreeAdvanced }, isLinearView() { return this.displayStyle === 'linear' }, shouldFadeAncestors() { - return this.$store.getters.mergedConfig.conversationTreeFadeAncestors + return useSyncConfigStore().mergedConfig.conversationTreeFadeAncestors }, otherRepliesButtonPosition() { - return this.$store.getters.mergedConfig.conversationOtherRepliesButton + return useSyncConfigStore().mergedConfig.conversationOtherRepliesButton }, showOtherRepliesButtonBelowStatus() { return this.otherRepliesButtonPosition === 'below' diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index 8ab54b3df..df7078afd 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -1,6 +1,9 @@ import SearchBar from 'components/search_bar/search_bar.vue' +import { mapState } from 'pinia' -import { useInterfaceStore } from 'src/stores/interface' +import { useInstanceStore } from 'src/stores/instance.js' +import { useInterfaceStore } from 'src/stores/interface.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import ConfirmModal from '../confirm_modal/confirm_modal.vue' import { library } from '@fortawesome/fontawesome-svg-core' @@ -31,6 +34,14 @@ library.add( faCog, faInfoCircle, ) +const supportsMask = + window.CSS && + window.CSS.supports && + (window.CSS.supports('mask-size', 'contain') || + window.CSS.supports('-webkit-mask-size', 'contain') || + window.CSS.supports('-moz-mask-size', 'contain') || + window.CSS.supports('-ms-mask-size', 'contain') || + window.CSS.supports('-o-mask-size', 'contain')) export default { components: { @@ -39,68 +50,51 @@ export default { }, data: () => ({ searchBarHidden: true, - supportsMask: - window.CSS && - window.CSS.supports && - (window.CSS.supports('mask-size', 'contain') || - window.CSS.supports('-webkit-mask-size', 'contain') || - window.CSS.supports('-moz-mask-size', 'contain') || - window.CSS.supports('-ms-mask-size', 'contain') || - window.CSS.supports('-o-mask-size', 'contain')), showingConfirmLogout: false, }), computed: { - enableMask() { - return this.supportsMask && this.$store.state.instance.logoMask - }, logoStyle() { return { - visibility: this.enableMask ? 'hidden' : 'visible', + visibility: this.logoMask ? 'hidden' : 'visible', } }, logoMaskStyle() { - return this.enableMask + return this.logoMask ? { - 'mask-image': `url(${this.$store.state.instance.logo})`, + 'mask-image': `url(${this.logo})`, } : { - 'background-color': this.enableMask ? '' : 'transparent', + 'background-color': this.logoMask ? '' : 'transparent', } }, logoBgStyle() { return Object.assign( { - margin: `${this.$store.state.instance.logoMargin} 0`, + margin: `${this.logoMargin} 0`, opacity: this.searchBarHidden ? 1 : 0, }, - this.enableMask + this.logoMask ? {} : { - 'background-color': this.enableMask ? '' : 'transparent', + 'background-color': this.logoMask ? '' : 'transparent', }, ) }, - logo() { - return this.$store.state.instance.logo - }, - sitename() { - return this.$store.state.instance.name - }, - hideSitename() { - return this.$store.state.instance.hideSitename - }, - logoLeft() { - return this.$store.state.instance.logoLeft - }, currentUser() { return this.$store.state.users.currentUser }, - privateMode() { - return this.$store.state.instance.private - }, shouldConfirmLogout() { - return this.$store.getters.mergedConfig.modalOnLogout + return useSyncConfigStore().mergedConfig.modalOnLogout }, + ...mapState(useInstanceStore, { + logo: (state) => state.instanceIdentity.logo, + logoMask: (state) => supportsMask && state.instanceIdentity.logoMask, + logoLeft: (state) => state.instanceIdentity.logoLeft, + logoMargin: (state) => state.instanceIdentity.logoMargin, + sitename: (state) => state.instanceIdentity.name, + privateMode: (state) => state.private, + hideSitename: (state) => state.instanceIdentity.hideSitename, + }), }, methods: { scrollToTop() { diff --git a/src/components/dialog_modal/dialog_modal.js b/src/components/dialog_modal/dialog_modal.js index 8070d3429..e5c399086 100644 --- a/src/components/dialog_modal/dialog_modal.js +++ b/src/components/dialog_modal/dialog_modal.js @@ -1,3 +1,5 @@ +import { useSyncConfigStore } from 'src/stores/sync_config.js' + const DialogModal = { props: { darkOverlay: { @@ -13,7 +15,7 @@ const DialogModal = { }, computed: { mobileCenter() { - return this.$store.getters.mergedConfig.modalMobileCenter + return useSyncConfigStore().mergedConfig.modalMobileCenter }, }, } diff --git a/src/components/draft/draft.js b/src/components/draft/draft.js index 971a75b10..5caaf7a96 100644 --- a/src/components/draft/draft.js +++ b/src/components/draft/draft.js @@ -5,6 +5,7 @@ import EditStatusForm from 'src/components/edit_status_form/edit_status_form.vue 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 { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faPollH } from '@fortawesome/free-solid-svg-icons' @@ -57,7 +58,7 @@ const Draft = { : undefined }, localCollapseSubjectDefault() { - return this.$store.getters.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 d724ab4ac..816ffd1ee 100644 --- a/src/components/draft_closer/draft_closer.js +++ b/src/components/draft_closer/draft_closer.js @@ -1,4 +1,5 @@ import DialogModal from 'src/components/dialog_modal/dialog_modal.vue' +import { useSyncConfigStore } from 'src/stores/sync_config.js' const DraftCloser = { data() { @@ -12,10 +13,10 @@ const DraftCloser = { emits: ['save', 'discard'], computed: { action() { - if (this.$store.getters.mergedConfig.autoSaveDraft) { + if (useSyncConfigStore().mergedConfig.autoSaveDraft) { return 'save' } else { - return this.$store.getters.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 24794640e..a9c024993 100644 --- a/src/components/emoji_input/emoji_input.js +++ b/src/components/emoji_input/emoji_input.js @@ -2,7 +2,8 @@ import { take } from 'lodash' import Popover from 'src/components/popover/popover.vue' import ScreenReaderNotice from 'src/components/screen_reader_notice/screen_reader_notice.vue' -import { ensureFinalFallback } from '../../i18n/languages.js' +import { ensureFinalFallback } from 'src/i18n/languages.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import Completion from '../../services/completion/completion.js' import { findOffset } from '../../services/offset_finder/offset_finder.service.js' import genRandomSeed from '../../services/random_seed/random_seed.service.js' @@ -131,10 +132,10 @@ const EmojiInput = { }, computed: { padEmoji() { - return this.$store.getters.mergedConfig.padEmoji + 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) @@ -163,7 +164,7 @@ const EmojiInput = { }, languages() { return ensureFinalFallback( - this.$store.getters.mergedConfig.interfaceLanguage, + useSyncConfigStore().mergedConfig.interfaceLanguage, ) }, maybeLocalizedEmojiNamesAndKeywords() { @@ -331,7 +332,6 @@ const EmojiInput = { if (!this.pickerShown) { this.scrollIntoView() this.$refs.picker.showPicker() - this.$refs.picker.startEmojiLoad() } else { this.$refs.picker.hidePicker() } diff --git a/src/components/emoji_input/suggestor.js b/src/components/emoji_input/suggestor.js index 79d97cff7..c0d8f7ca1 100644 --- a/src/components/emoji_input/suggestor.js +++ b/src/components/emoji_input/suggestor.js @@ -1,8 +1,10 @@ +import { useEmojiStore } from 'src/stores/emoji.js' + /** * suggest - generates a suggestor function to be used by emoji-input * data: object providing source information for specific types of suggestions: * data.emoji - optional, an array of all emoji available i.e. - * (getters.standardEmojiList + state.instance.customEmoji) + * (useEmojiStore().standardEmojiList + state.instance.customEmoji) * data.users - optional, an array of all known users * updateUsersList - optional, a function to search and append to users * diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js index e4221f706..2644d53e4 100644 --- a/src/components/emoji_picker/emoji_picker.js +++ b/src/components/emoji_picker/emoji_picker.js @@ -2,7 +2,10 @@ import { chunk, debounce, trim } from 'lodash' import { defineAsyncComponent } from 'vue' import Popover from 'src/components/popover/popover.vue' -import { ensureFinalFallback } from '../../i18n/languages.js' +import { ensureFinalFallback } from 'src/i18n/languages.js' +import { useInstanceStore } from 'src/stores/instance.js' +import { useEmojiStore } from 'src/stores/emoji.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import Checkbox from '../checkbox/checkbox.vue' import StillImage from '../still-image/still-image.vue' @@ -337,7 +340,7 @@ const EmojiPicker = { this.$nextTick(() => { this.updateEmojiSize() }) - return this.$store.getters.mergedConfig.fontSize + return useSyncConfigStore().mergedConfig.fontSize }, emojiHeight() { return this.emojiSize @@ -349,8 +352,8 @@ const EmojiPicker = { return this.showingStickers ? '' : this.activeGroup }, stickersAvailable() { - if (this.$store.state.instance.stickers) { - return this.$store.state.instance.stickers.length > 0 + if (useInstanceStore().stickers) { + return useInstanceStore().stickers.length > 0 } return 0 }, @@ -358,7 +361,7 @@ const EmojiPicker = { if (this.hideCustomEmoji || this.hideCustomEmojiInPicker) { return {} } - const emojis = this.$store.getters.groupedCustomEmojis + const emojis = useEmojiStore().groupedCustomEmojis if (emojis.unpacked) { emojis.unpacked.text = this.$t('emoji.unpacked') } @@ -368,7 +371,7 @@ const EmojiPicker = { return Object.keys(this.allCustomGroups)[0] }, unicodeEmojiGroups() { - return this.$store.getters.standardEmojiGroupList.map((group) => ({ + return useEmojiStore().standardEmojiGroupList.map((group) => ({ id: `standard-${group.id}`, text: this.$t(`emoji.unicode_groups.${group.id}`), icon: UNICODE_EMOJI_GROUP_ICON[group.id], @@ -381,7 +384,7 @@ const EmojiPicker = { .concat(this.unicodeEmojiGroups) }, stickerPickerEnabled() { - return (this.$store.state.instance.stickers || []).length !== 0 + return (useInstanceStore().stickers || []).length !== 0 }, debouncedHandleKeywordChange() { return debounce(() => { @@ -402,7 +405,7 @@ const EmojiPicker = { }, languages() { return ensureFinalFallback( - this.$store.getters.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 1deebd878..59c6405ac 100644 --- a/src/components/extra_notifications/extra_notifications.js +++ b/src/components/extra_notifications/extra_notifications.js @@ -1,8 +1,9 @@ -import { mapState as mapPiniaState } from 'pinia' +import { mapState } from 'pinia' import { mapGetters } from 'vuex' -import { useAnnouncementsStore } from 'src/stores/announcements' -import { useInterfaceStore } from 'src/stores/interface' +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 { @@ -51,10 +52,11 @@ const ExtraNotifications = { currentUser() { return this.$store.state.users.currentUser }, - ...mapGetters(['unreadChatCount', 'followRequestCount', 'mergedConfig']), - ...mapPiniaState(useAnnouncementsStore, { + ...mapGetters(['unreadChatCount', 'followRequestCount']), + ...mapState(useAnnouncementsStore, { unreadAnnouncementCount: 'unreadAnnouncementCount', }), + ...mapState(useSyncConfigStore, ['mergedConfig']), }, methods: { openNotificationSettings() { diff --git a/src/components/features_panel/features_panel.js b/src/components/features_panel/features_panel.js index e92cb975e..3b46e6f68 100644 --- a/src/components/features_panel/features_panel.js +++ b/src/components/features_panel/features_panel.js @@ -1,31 +1,32 @@ +import { useInstanceStore } from 'src/stores/instance.js' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' const FeaturesPanel = { computed: { shout: function () { - return this.$store.state.instance.shoutAvailable + return useInstanceStore().shoutAvailable }, pleromaChatMessages: function () { - return this.$store.state.instance.pleromaChatMessagesAvailable + return useInstanceStore().pleromaChatMessagesAvailable }, gopher: function () { - return this.$store.state.instance.gopherAvailable + return useInstanceStore().gopherAvailable }, whoToFollow: function () { - return this.$store.state.instance.suggestionsEnabled + return useInstanceStore().suggestionsEnabled }, mediaProxy: function () { - return this.$store.state.instance.mediaProxyAvailable + return useInstanceStore().mediaProxyAvailable }, minimalScopesMode: function () { - return this.$store.state.instance.minimalScopesMode + return useInstanceStore().minimalScopesMode }, textlimit: function () { - return this.$store.state.instance.textlimit + return useInstanceStore().textlimit }, uploadlimit: function () { return fileSizeFormatService.fileSizeFormat( - this.$store.state.instance.uploadlimit, + useInstanceStore().uploadlimit, ) }, }, diff --git a/src/components/follow_button/follow_button.js b/src/components/follow_button/follow_button.js index eb545b28d..6c2186a89 100644 --- a/src/components/follow_button/follow_button.js +++ b/src/components/follow_button/follow_button.js @@ -1,3 +1,4 @@ +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { requestFollow, requestUnfollow, @@ -16,7 +17,7 @@ export default { }, computed: { shouldConfirmUnfollow() { - return this.$store.getters.mergedConfig.modalOnUnfollow + return useSyncConfigStore().mergedConfig.modalOnUnfollow }, isPressed() { return this.inProgress || this.relationship.following diff --git a/src/components/follow_request_card/follow_request_card.js b/src/components/follow_request_card/follow_request_card.js index c037ddf42..fa5487ec4 100644 --- a/src/components/follow_request_card/follow_request_card.js +++ b/src/components/follow_request_card/follow_request_card.js @@ -1,3 +1,4 @@ +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { notificationsFromStore } from '../../services/notification_utils/notification_utils.js' import BasicUserCard from '../basic_user_card/basic_user_card.vue' import ConfirmModal from '../confirm_modal/confirm_modal.vue' @@ -76,7 +77,7 @@ const FollowRequestCard = { }, computed: { mergedConfig() { - return this.$store.getters.mergedConfig + return useSyncConfigStore().mergedConfig }, shouldConfirmApprove() { return this.mergedConfig.modalOnApproveFollow diff --git a/src/components/instance_specific_panel/instance_specific_panel.js b/src/components/instance_specific_panel/instance_specific_panel.js index eead52f40..c9e2e280f 100644 --- a/src/components/instance_specific_panel/instance_specific_panel.js +++ b/src/components/instance_specific_panel/instance_specific_panel.js @@ -1,7 +1,9 @@ +import { useInstanceStore } from 'src/stores/instance.js' + const InstanceSpecificPanel = { computed: { instanceSpecificPanelContent() { - return this.$store.state.instance.instanceSpecificPanelContent + return useInstanceStore().instanceSpecificPanelContent }, }, } diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index 8dc3d6c65..89561f3e3 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -1,5 +1,4 @@ -/* eslint-env browser */ - +import { useSyncConfigStore } from 'src/stores/sync_config.js' import fileSizeFormatService from '../../services/file_size_format/file_size_format.js' import statusPosterService from '../../services/status_poster/status_poster.service.js' @@ -33,7 +32,7 @@ const mediaUpload = { } // Skip if image compression is disabled - if (!this.$store.getters.mergedConfig.imageCompression) { + if (!useSyncConfigStore().mergedConfig.imageCompression) { return file } @@ -78,7 +77,7 @@ const mediaUpload = { // Convert to WebP if supported and alwaysUseJpeg is false, otherwise JPEG const type = - !this.$store.getters.mergedConfig.alwaysUseJpeg && supportsWebP + !useSyncConfigStore().mergedConfig.alwaysUseJpeg && supportsWebP ? 'image/webp' : 'image/jpeg' const extension = type === 'image/webp' ? '.webp' : '.jpg' diff --git a/src/components/mention_link/mention_link.js b/src/components/mention_link/mention_link.js index 4c211b5e9..d9580d8a2 100644 --- a/src/components/mention_link/mention_link.js +++ b/src/components/mention_link/mention_link.js @@ -1,6 +1,8 @@ import { defineAsyncComponent } from 'vue' import { mapGetters, mapState } from 'vuex' +import { mapState as mapPiniaState } from 'pinia' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' import { highlightClass, @@ -97,7 +99,7 @@ const MentionLink = { return this.user && this.user.screen_name_ui }, highlight() { - return this.user && this.mergedConfig.highlight[this.user.screen_name] + return this.user && useSyncConfigStore().mergedConfig.highlight[this.user.screen_name] }, highlightType() { return this.highlight && '-' + this.highlight.type @@ -130,7 +132,7 @@ const MentionLink = { return this.userName !== this.userNameFull }, shouldShowFullUserName() { - const conf = this.mergedConfig.mentionLinkDisplay + const conf = useSyncConfigStore().mergedConfig.mentionLinkDisplay if (conf === 'short') { return false } else if (conf === 'full') { @@ -140,25 +142,16 @@ const MentionLink = { return this.isRemote } }, - shouldShowTooltip() { - return this.mergedConfig.mentionLinkShowTooltip - }, - shouldShowAvatar() { - return this.mergedConfig.mentionLinkShowAvatar - }, - shouldShowYous() { - return this.mergedConfig.mentionLinkShowYous - }, - shouldBoldenYou() { - return this.mergedConfig.mentionLinkBoldenYou - }, - shouldFadeDomain() { - return this.mergedConfig.mentionLinkFadeDomain - }, - ...mapGetters(['mergedConfig']), ...mapState({ currentUser: (state) => state.users.currentUser, }), + ...mapPiniaState(useSyncConfigStore, { + shouldShowTooltip: (state) => state.mergedConfig.mentionLinkShowTooltip, + shouldShowAvatar: (state) => state.mergedConfig.mentionLinkShowAvatar, + shouldShowYous: (state) => state.mergedConfig.mentionLinkShowYous, + shouldBoldenYou: (state) => state.mergedConfig.mentionLinkBoldenYou, + shouldFadeDomain: (state) => state.mergedConfig.mentionLinkFadeDomain, + }), }, } diff --git a/src/components/mobile_nav/mobile_nav.js b/src/components/mobile_nav/mobile_nav.js index 873bdc40d..33767762e 100644 --- a/src/components/mobile_nav/mobile_nav.js +++ b/src/components/mobile_nav/mobile_nav.js @@ -3,7 +3,8 @@ import { mapGetters } from 'vuex' import NavigationPins from 'src/components/navigation/navigation_pins.vue' import { useAnnouncementsStore } from 'src/stores/announcements' -import { useServerSideStorageStore } from 'src/stores/serverSideStorage' +import { useInstanceStore } from 'src/stores/instance.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import GestureService from '../../services/gesture_service/gesture_service' import { countExtraNotifications, @@ -64,24 +65,24 @@ const MobileNav = { return `${this.unseenCount ? this.unseenCount : ''}` }, hideSitename() { - return this.$store.state.instance.hideSitename + return useInstanceStore().hideSitename }, sitename() { - return this.$store.state.instance.name + return useInstanceStore().name }, isChat() { return this.$route.name === 'chat' }, ...mapState(useAnnouncementsStore, ['unreadAnnouncementCount']), - ...mapState(useServerSideStorageStore, { + ...mapState(useSyncConfigStore, { pinnedItems: (store) => new Set(store.prefsStorage.collections.pinnedNavItems).has('chats'), }), shouldConfirmLogout() { - return this.$store.getters.mergedConfig.modalOnLogout + return useSyncConfigStore().mergedConfig.modalOnLogout }, closingDrawerMarksAsSeen() { - return this.$store.getters.mergedConfig.closingDrawerMarksAsSeen + return useSyncConfigStore().mergedConfig.closingDrawerMarksAsSeen }, ...mapGetters(['unreadChatCount']), }, diff --git a/src/components/mobile_post_status_button/mobile_post_status_button.js b/src/components/mobile_post_status_button/mobile_post_status_button.js index dfa7b6fe2..115c2ab4c 100644 --- a/src/components/mobile_post_status_button/mobile_post_status_button.js +++ b/src/components/mobile_post_status_button/mobile_post_status_button.js @@ -1,6 +1,7 @@ import { debounce } from 'lodash' import { usePostStatusStore } from 'src/stores/post_status' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faPen } from '@fortawesome/free-solid-svg-icons' @@ -45,10 +46,10 @@ const MobilePostStatusButton = { ) }, isPersistent() { - return !!this.$store.getters.mergedConfig.alwaysShowNewPostButton + return !!useSyncConfigStore().mergedConfig.alwaysShowNewPostButton }, autohideFloatingPostButton() { - return !!this.$store.getters.mergedConfig.autohideFloatingPostButton + return !!useSyncConfigStore().mergedConfig.autohideFloatingPostButton }, }, watch: { diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index fdb8a74b6..f4c5e0470 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -1,3 +1,4 @@ +import { useInstanceStore } from 'src/stores/instance.js' import DialogModal from '../dialog_modal/dialog_modal.vue' import Popover from '../popover/popover.vue' @@ -54,7 +55,7 @@ const ModerationTools = { }, canUseTagPolicy() { return ( - this.$store.state.instance.tagPolicyAvailable && + useInstanceStore().tagPolicyAvailable && this.privileged('users_manage_tags') ) }, diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 36b6fe95d..97364fab7 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -10,7 +10,7 @@ import NavigationEntry from 'src/components/navigation/navigation_entry.vue' import NavigationPins from 'src/components/navigation/navigation_pins.vue' import { useAnnouncementsStore } from 'src/stores/announcements.js' import { useInstanceStore } from 'src/stores/instance.js' -import { useServerSideStorageStore } from 'src/stores/serverSideStorage.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -82,28 +82,28 @@ const NavPanel = { this.editMode = !this.editMode }, toggleCollapse() { - useServerSideStorageStore().setPreference({ + useSyncConfigStore().setPreference({ path: 'simple.collapseNav', value: !this.collapsed, }) - useServerSideStorageStore().pushServerSideStorage() + useSyncConfigStore().pushSyncConfig() }, isPinned(item) { return this.pinnedItems.has(item) }, togglePin(item) { if (this.isPinned(item)) { - useServerSideStorageStore().removeCollectionPreference({ + useSyncConfigStore().removeCollectionPreference({ path: 'collections.pinnedNavItems', value: item, }) } else { - useServerSideStorageStore().addCollectionPreference({ + useSyncConfigStore().addCollectionPreference({ path: 'collections.pinnedNavItems', value: item, }) } - useServerSideStorageStore().pushServerSideStorage() + useSyncConfigStore().pushSyncConfig() }, }, computed: { @@ -111,7 +111,7 @@ const NavPanel = { unreadAnnouncementCount: 'unreadAnnouncementCount', supportsAnnouncements: (store) => store.supportsAnnouncements, }), - ...mapPiniaState(useServerSideStorageStore, { + ...mapPiniaState(useSyncConfigStore, { collapsed: (store) => store.prefsStorage.simple.collapseNav, pinnedItems: (store) => new Set(store.prefsStorage.collections.pinnedNavItems), @@ -123,12 +123,12 @@ const NavPanel = { store.featureSet.pleromaChatMessagesAvailable, bookmarkFolders: (store) => store.featureSet.pleromaBookmarkFoldersAvailable, + privateMode: (state) => state.private, + federating: (state) => state.federating, }), ...mapState({ currentUser: (state) => state.users.currentUser, followRequestCount: (state) => state.api.followRequests.length, - privateMode: (state) => state.instance.private, - federating: (state) => state.instance.federating, }), timelinesItems() { return filterNavigation( diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js index 75d4dffdd..46f1695ad 100644 --- a/src/components/navigation/navigation_entry.js +++ b/src/components/navigation/navigation_entry.js @@ -4,7 +4,7 @@ import { mapState } from 'vuex' import { routeTo } from 'src/components/navigation/navigation.js' import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue' import { useAnnouncementsStore } from 'src/stores/announcements' -import { useServerSideStorageStore } from 'src/stores/serverSideStorage' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faThumbtack } from '@fortawesome/free-solid-svg-icons' @@ -22,17 +22,17 @@ const NavigationEntry = { }, togglePin(value) { if (this.isPinned(value)) { - useServerSideStorageStore().removeCollectionPreference({ + useSyncConfigStore().removeCollectionPreference({ path: 'collections.pinnedNavItems', value, }) } else { - useServerSideStorageStore().addCollectionPreference({ + useSyncConfigStore().addCollectionPreference({ path: 'collections.pinnedNavItems', value, }) } - useServerSideStorageStore().pushServerSideStorage() + useSyncConfigStore().pushSyncConfig() }, }, computed: { @@ -46,7 +46,7 @@ const NavigationEntry = { ...mapState({ currentUser: (state) => state.users.currentUser, }), - ...mapPiniaState(useServerSideStorageStore, { + ...mapPiniaState(useSyncConfigStore, { pinnedItems: (store) => new Set(store.prefsStorage.collections.pinnedNavItems), }), diff --git a/src/components/navigation/navigation_pins.js b/src/components/navigation/navigation_pins.js index c4979086f..99b5292eb 100644 --- a/src/components/navigation/navigation_pins.js +++ b/src/components/navigation/navigation_pins.js @@ -14,9 +14,9 @@ import { import StillImage from 'src/components/still-image/still-image.vue' import { useAnnouncementsStore } from 'src/stores/announcements' import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders' -import { useListsStore } from 'src/stores/lists' import { useInstanceStore } from 'src/stores/instance' -import { useServerSideStorageStore } from 'src/stores/serverSideStorage' +import { useListsStore } from 'src/stores/lists' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { library } from '@fortawesome/fontawesome-svg-core' import { @@ -68,15 +68,17 @@ const NavPanel = { ...mapPiniaState(useBookmarkFoldersStore, { bookmarks: getBookmarkFolderEntries, }), - ...mapPiniaState(useServerSideStorageStore, { + ...mapPiniaState(useSyncConfigStore, { pinnedItems: (store) => new Set(store.prefsStorage.collections.pinnedNavItems), }), ...mapPiniaState(useInstanceStore, { privateMode: (store) => store.featureSet.private, federating: (store) => store.featureSet.federating, - pleromaChatMessagesAvailable: (store) => store.featureSet.pleromaChatMessagesAvailable, - bubbleTimelinesSupported: (store) => store.featureSet.localBubbleInstances.length > 0, + pleromaChatMessagesAvailable: (store) => + store.featureSet.pleromaChatMessagesAvailable, + bubbleTimelinesSupported: (store) => + store.featureSet.localBubbleInstances.length > 0, }), ...mapState({ currentUser: (state) => state.users.currentUser, diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js index 275827c43..35644d070 100644 --- a/src/components/notification/notification.js +++ b/src/components/notification/notification.js @@ -2,6 +2,8 @@ import { mapState } from 'vuex' import RichContent from 'src/components/rich_content/rich_content.jsx' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' +import { useInstanceStore } from 'src/stores/instance.js' +import { useSyncConfigStore } from 'src/stores/sync_config.js' import { isStatusNotification } from '../../services/notification_utils/notification_utils.js' import { highlightClass, @@ -107,7 +109,7 @@ const Notification = { return generateProfileLink( user.id, user.screen_name, - this.$store.state.instance.restrictedNicknames, + useInstanceStore().restrictedNicknames, ) }, getUser(notification) { @@ -178,7 +180,7 @@ const Notification = { return highlightClass(this.notification.from_profile) }, userStyle() { - const highlight = this.$store.getters.mergedConfig.highlight + const highlight = useSyncConfigStore().mergedConfig.highlight const user = this.notification.from_profile return highlightStyle(highlight[user.screen_name]) }, @@ -206,7 +208,7 @@ const Notification = { return isStatusNotification(this.notification.type) }, mergedConfig() { - return this.$store.getters.mergedConfig + return useSyncConfigStore().mergedConfig }, shouldConfirmApprove() { return this.mergedConfig.modalOnApproveFollow diff --git a/src/components/notifications/notification_filters.vue b/src/components/notifications/notification_filters.vue index 7be8eb76b..d01e5e9ab 100644 --- a/src/components/notifications/notification_filters.vue +++ b/src/components/notifications/notification_filters.vue @@ -106,6 +106,7 @@