This commit is contained in:
Henry Jameson 2026-01-22 20:52:47 +02:00
commit 35a3d59235
12 changed files with 80 additions and 65 deletions

View file

@ -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 {

View file

@ -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

View file

@ -87,7 +87,7 @@ const conversation = {
},
streamingEnabled() {
return (
this.mergedConfig.useStreamingApi &&
useSyncConfigStore().mergedConfig.useStreamingApi &&
this.mastoUserSocketStatus === WSConnectionStatus.JOINED
)
},

View file

@ -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) =>

View file

@ -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,

View file

@ -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(''),

View file

@ -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,

View file

@ -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,
}),

View file

@ -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: {

View file

@ -357,7 +357,7 @@
<RichContent
v-if="!hideBio"
class="user-card-bio"
:class="{ '-justify-left': mergedConfig.userCardLeftJustify }"
:class="{ '-justify-left': userCardLeftJustify }"
:html="editable ? newBio.replace(/\n/g, '<br>') : user.description_html"
:emoji="editable ? emoji : user.emoji"
:handle-links="true"
@ -368,7 +368,7 @@
v-model="newBio"
enable-emoji-picker
class="user-card-bio"
:class="{ '-justify-left': mergedConfig.userCardLeftJustify }"
:class="{ '-justify-left': userCardLeftJustify }"
:suggest="emojiUserSuggestor"
>
<template #default="inputProps">

View file

@ -4,6 +4,7 @@ const browserLocale = (window.navigator.language || 'en').split('-')[0]
/// Put settings here only if it does not make sense for a normal user
/// to override it.
export const staticOrApiConfigDefault = {
name: 'PleromaFE',
theme: 'pleroma-dark',
palette: null,
style: null,
@ -18,7 +19,7 @@ export const staticOrApiConfigDefault = {
redirectRootLogin: '/main/friends',
redirectRootNoLogin: '/main/all',
hideSitename: false,
nsfwCensorImage: undefined,
nsfwCensorImage: null,
showFeaturesPanel: true,
showInstanceSpecificPanel: false,
}
@ -93,7 +94,7 @@ export const instanceDefaultConfig = {
sidebarRight: false,
scopeCopy: true,
subjectLineBehavior: 'email',
alwaysShowSubjectInput: false,
alwaysShowSubjectInput: true,
postContentType: 'text/plain',
minimalScopesMode: false,

View file

@ -18,11 +18,6 @@ const defaultState = {
registrationOpen: true,
server: 'http://localhost:4040/',
textlimit: 5000,
bannerlimit: null,
avatarlimit: null,
backgroundlimit: null,
uploadlimit: null,
fieldsLimits: null,
private: false,
federating: true,
federationPolicy: null,
@ -41,6 +36,20 @@ const defaultState = {
...staticOrApiConfigDefault,
},
limits: {
bannerlimit: null,
avatarlimit: null,
backgroundlimit: null,
uploadlimit: null,
fieldsLimits: null,
pollLimits: {
max_options: 4,
max_option_chars: 255,
min_expiration: 60,
max_expiration: 60 * 60 * 24,
},
},
// Instance admins can override default settings for the whole instance
prefsStorage: {
...instanceDefaultConfig,
@ -56,6 +65,7 @@ const defaultState = {
birthdayRequired: false,
birthdayMinAge: 0,
restrictedNicknames: [],
localBubbleInstances: [], // Akkoma
// Feature-set, apparently, not everything here is reported...
featureSet: {
@ -79,7 +89,7 @@ const defaultState = {
blockExpiration: false,
tagPolicyAvailable: false,
pollsAvailable: false,
localBubbleInstances: [], // Akkoma
localBubble: false, // Akkoma
},
// Html stuff
@ -90,14 +100,6 @@ const defaultState = {
backendVersion: '',
backendRepository: '',
frontendVersion: '',
pollsAvailable: false,
pollLimits: {
max_options: 4,
max_option_chars: 255,
min_expiration: 60,
max_expiration: 60 * 60 * 24,
},
}
export const useInstanceStore = defineStore('instance', {