diff --git a/src/boot/after_store.js b/src/boot/after_store.js index e89e3abcb..fab948cf2 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -172,6 +172,7 @@ const setSettings = async ({ apiConfig, staticConfig, store }) => { }) } } + console.log(config) const copyInstancePrefOption = (path) => { if (get(config, path) !== undefined) { @@ -277,14 +278,26 @@ const getNodeInfo = async ({ store }) => { const data = await res.json() const metadata = data.metadata const features = metadata.features + useInstanceStore().set({ - path: 'name', + path: 'localBubbleInstances', + value: metadata.localBubbleInstances ?? [], + }) + + useInstanceStore().set({ + path: 'instanceIdentity.name', value: metadata.nodeName, }) + useInstanceStore().set({ path: 'registrationOpen', value: data.openRegistrations, }) + useInstanceStore().set({ + path: 'restrictedNicknames', + value: metadata.restrictedNicknames, + }) + useInstanceStore().set({ path: 'featureSet.mediaProxyAvailable', value: features.includes('media_proxy'), @@ -323,10 +336,6 @@ const getNodeInfo = async ({ store }) => { path: 'featureSet.editingAvailable', value: features.includes('editing'), }) - useInstanceStore().set({ - path: 'pollLimits', - value: metadata.pollLimits, - }) useInstanceStore().set({ path: 'featureSet.mailerEnabled', value: metadata.mailerEnabled, @@ -344,35 +353,34 @@ const getNodeInfo = async ({ store }) => { value: features.includes('pleroma:block_expiration'), }) useInstanceStore().set({ - path: 'featureSet.localBubbleInstances', - value: metadata.localBubbleInstances ?? [], + path: 'featureSet.localBubble', + value: Array.isArray(metadata.localBubbleInstances), }) const uploadLimits = metadata.uploadLimits useInstanceStore().set({ - path: 'uploadlimit', + path: 'limits.uploadlimit', value: parseInt(uploadLimits.general), }) useInstanceStore().set({ - path: 'avatarlimit', + path: 'limits.avatarlimit', value: parseInt(uploadLimits.avatar), }) useInstanceStore().set({ - path: 'backgroundlimit', + path: 'limits.backgroundlimit', value: parseInt(uploadLimits.background), }) useInstanceStore().set({ - path: 'bannerlimit', + path: 'limits.bannerlimit', value: parseInt(uploadLimits.banner), }) useInstanceStore().set({ - path: 'fieldsLimits', + path: 'limits.fieldsLimits', value: metadata.fieldsLimits, }) - useInstanceStore().set({ - path: 'restrictedNicknames', - value: metadata.restrictedNicknames, + path: 'limits.pollLimits', + value: metadata.pollLimits, }) useInstanceStore().set({ path: 'featureSet.postFormats', @@ -389,6 +397,8 @@ const getNodeInfo = async ({ store }) => { value: suggestions.web, }) + // + const software = data.software useInstanceStore().set({ path: 'backendVersion', @@ -399,8 +409,7 @@ const getNodeInfo = async ({ store }) => { value: software.repository, }) - const priv = metadata.private - useInstanceStore().set({ path: 'private', value: priv }) + useInstanceStore().set({ path: 'private', value: metadata.private }) const frontendVersion = window.___pleromafe_commit_hash useInstanceStore().set({ @@ -422,6 +431,7 @@ const getNodeInfo = async ({ store }) => { path: 'federationPolicy', value: federation, }) + useInstanceStore().set({ path: 'federating', value: @@ -542,7 +552,6 @@ 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/components/attachment/attachment.js b/src/components/attachment/attachment.js index 2b3211cb3..af3bf3d69 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,5 @@ import { mapGetters } from 'vuex' +import { mapState } from 'pinia' import { useInstanceStore } from 'src/stores/instance.js' import { useMediaViewerStore } from 'src/stores/media_viewer' @@ -55,7 +56,7 @@ const Attachment = { data() { return { localDescription: this.description || this.attachment.description, - nsfwImage: useInstanceStore().nsfwCensorImage || nsfwImage, + nsfwImage: useInstanceStore().instanceIdentity.nsfwCensorImage || nsfwImage, hideNsfwLocal: useSyncConfigStore().mergedConfig.hideNsfw, preloadImage: useSyncConfigStore().mergedConfig.preloadImage, loading: false, @@ -90,9 +91,6 @@ const Attachment = { usePlaceholder() { return this.size === 'hide' }, - useContainFit() { - return useSyncConfigStore().mergedConfig.useContainFit - }, placeholderName() { if (this.attachment.description === '' || !this.attachment.description) { return this.type.toUpperCase() @@ -125,7 +123,7 @@ const Attachment = { modalTypes = ['image', 'video', 'audio', 'flash'] break default: - modalTypes = this.mergedConfig.playVideosInModal + modalTypes = this.playVideosInModal ? ['image', 'video', 'flash'] : ['image'] break @@ -135,7 +133,11 @@ const Attachment = { videoTag() { return this.useModal ? 'button' : 'span' }, - ...mapGetters(['mergedConfig']), + ...mapState(useSyncConfigStore, { + useContainFit: (state) => state.mergedConfig.useContainFit, + playVideosInModal: (state) => state.mergedConfig.playVideosInModal, + useOneClickNsfw: (state) => state.mergedConfig.useOneClickNsfw, + }), }, watch: { 'attachment.description'(newVal) { @@ -186,9 +188,9 @@ const Attachment = { }, toggleHidden(event) { if ( - this.mergedConfig.useOneClickNsfw && + this.useOneClickNsfw && !this.showHidden && - (this.type !== 'video' || this.mergedConfig.playVideosInModal) + (this.type !== 'video' || this.playVideosInModal) ) { this.openModal(event) return diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index fe654cba2..84b33b3a2 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -87,7 +87,7 @@ const conversation = { }, streamingEnabled() { return ( - this.mergedConfig.useStreamingApi && + useSyncConfigStore().mergedConfig.useStreamingApi && this.mastoUserSocketStatus === WSConnectionStatus.JOINED ) }, diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 97364fab7..6be7787c0 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -118,7 +118,7 @@ const NavPanel = { }), ...mapPiniaState(useInstanceStore, { bubbleTimeline: (store) => - store.featureSet.localBubbleInstances.length > 0, + store.featureSet.localBubble, pleromaChatMessagesAvailable: (store) => store.featureSet.pleromaChatMessagesAvailable, bookmarkFolders: (store) => diff --git a/src/components/navigation/navigation_pins.js b/src/components/navigation/navigation_pins.js index 99b5292eb..1789a6d9c 100644 --- a/src/components/navigation/navigation_pins.js +++ b/src/components/navigation/navigation_pins.js @@ -78,7 +78,7 @@ const NavPanel = { pleromaChatMessagesAvailable: (store) => store.featureSet.pleromaChatMessagesAvailable, bubbleTimelinesSupported: (store) => - store.featureSet.localBubbleInstances.length > 0, + store.featureSet.localBubble, }), ...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 d1a6845d1..67219cb77 100644 --- a/src/components/status_action_buttons/buttons_definitions.js +++ b/src/components/status_action_buttons/buttons_definitions.js @@ -49,8 +49,8 @@ export const BUTTONS = [ (currentUser.id === status.user.id || !PRIVATE_SCOPES.has(status.visibility)), toggleable: true, - confirm: ({ status, getters }) => - !status.repeated && getters.mergedConfig.modalOnRepeat, + confirm: ({ status, mergedConfig }) => + !status.repeated && mergedConfig.modalOnRepeat, confirmStrings: { title: 'status.repeat_confirm_title', body: 'status.repeat_confirm', @@ -158,8 +158,8 @@ export const BUTTONS = [ name: 'editHistory', icon: 'history', label: 'status.status_history', - if({ status, state }) { - return state.instance.editingAvailable && status.edited_at !== null + if({ status, instance }) { + return instance.editingAvailable && status.edited_at !== null }, action({ status }) { const originalStatus = { ...status } @@ -186,10 +186,10 @@ export const BUTTONS = [ name: 'edit', icon: 'pen', label: 'status.edit', - if({ status, loggedIn, currentUser, state }) { + if({ status, loggedIn, currentUser, instance }) { return ( loggedIn && - state.instance.editingAvailable && + instance.editingAvailable && status.user.id === currentUser.id ) }, @@ -222,7 +222,7 @@ export const BUTTONS = [ currentUser.privileges.includes('messages_delete')) ) }, - confirm: ({ getters }) => getters.mergedConfig.modalOnDelete, + confirm: ({ mergedConfig }) => mergedConfig.modalOnDelete, confirmStrings: { title: 'status.delete_confirm_title', body: 'status.delete_confirm', @@ -240,10 +240,10 @@ export const BUTTONS = [ name: 'share', icon: 'share-alt', label: 'status.copy_link', - action({ state, status, router }) { + action({ instance, status, router }) { navigator.clipboard.writeText( [ - state.instance.server, + instance.server, router.resolve({ name: 'conversation', params: { id: status.id } }) .href, ].join(''), diff --git a/src/components/status_action_buttons/status_action_buttons.js b/src/components/status_action_buttons/status_action_buttons.js index af1584e0e..36a80216a 100644 --- a/src/components/status_action_buttons/status_action_buttons.js +++ b/src/components/status_action_buttons/status_action_buttons.js @@ -4,6 +4,7 @@ import ConfirmModal from 'src/components/confirm_modal/confirm_modal.vue' import Popover from 'src/components/popover/popover.vue' import genRandomSeed from 'src/services/random_seed/random_seed.service.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { useInstanceStore } from 'src/stores/instance.js' import ActionButtonContainer from './action_button_container.vue' import { BUTTONS } from './buttons_definitions.js' @@ -56,8 +57,8 @@ const StatusActionButtons = { replying: this.replying, emit: this.$emit, dispatch: this.$store.dispatch, - state: this.$store.state, - getters: this.$store.getters, + instance: useInstanceStore(), + mergedConfig: useSyncConfigStore().mergedConfig, router: this.$router, currentUser: this.currentUser, loggedIn: !!this.currentUser, diff --git a/src/components/timeline_menu/timeline_menu.js b/src/components/timeline_menu/timeline_menu.js index 7a7dad77b..15756bcdc 100644 --- a/src/components/timeline_menu/timeline_menu.js +++ b/src/components/timeline_menu/timeline_menu.js @@ -67,7 +67,7 @@ const TimelineMenu = { bookmarkFolders: (state) => state.featureSet.pleromaBookmarkFoldersAvailable, bubbleTimeline: (state) => - state.featureSet.localBubbleInstances.length > 0, + state.featureSet.localBubble, privateMode: (state) => state.private, federating: (state) => state.federating, }), diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index d9cc42420..99c40fe87 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -220,11 +220,11 @@ export default { }, userHighlightType: { get() { - const data = this.mergedConfig.highlight[this.user.screen_name] + const data = this.highlight[this.user.screen_name] return (data && data.type) || 'disabled' }, set(type) { - const data = this.mergedConfig.highlight[this.user.screen_name] + const data = this.highlight[this.user.screen_name] if (type !== 'disabled') { this.$store.dispatch('setHighlight', { user: this.user.screen_name, @@ -241,7 +241,7 @@ export default { }, userHighlightColor: { get() { - const data = this.mergedConfig.highlight[this.user.screen_name] + const data = this.highlight[this.user.screen_name] return data && data.color }, set(color) { @@ -384,11 +384,11 @@ export default { ], }) }, - ...mapGetters(['mergedConfig']), ...mapState(useSyncConfigStore, { - hideUserStats: (store) => store.prefsStorage.simple.hideUserStats, + hideUserStats: (store) => store.mergedConfig.hideUserStats, + userCardLeftJustify: (store) => store.mergedConfig.userCardLeftJustify, userCardHidePersonalMarks: (store) => - store.prefsStorage.simple.userCardHidePersonalMarks, + store.mergedConfig.userCardHidePersonalMarks, }), }, methods: { diff --git a/src/components/user_card/user_card.vue b/src/components/user_card/user_card.vue index e3b061e0c..111b6b999 100644 --- a/src/components/user_card/user_card.vue +++ b/src/components/user_card/user_card.vue @@ -357,7 +357,7 @@