Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
38 KB
Referenced Files
None
Subscribers
None
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index df641f67b9..5c2aaa6efb 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -1,615 +1,616 @@
/* global process */
import vClickOutside from 'click-outside-vue3'
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import VueVirtualScroller from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import { config } from '@fortawesome/fontawesome-svg-core'
import {
FontAwesomeIcon,
FontAwesomeLayers,
} from '@fortawesome/vue-fontawesome'
config.autoAddCss = false
import App from '../App.vue'
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import FaviconService from '../services/favicon_service/favicon_service.js'
import { applyStyleConfig } from '../services/style_setter/style_setter.js'
import { initServiceWorker, updateFocus } from '../services/sw/sw.js'
import {
windowHeight,
windowWidth,
} from '../services/window_utils/window_utils'
import routes from './routes'
import { useAnnouncementsStore } from 'src/stores/announcements'
import { useAuthFlowStore } from 'src/stores/auth_flow'
import { useEmojiStore } from 'src/stores/emoji.js'
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 { useUserHighlightStore } from 'src/stores/user_highlight.js'
import VBodyScrollLock from 'src/directives/body_scroll_lock'
import {
- instanceDefaultConfig,
- instanceIdentityDefaultDefinition,
+ instanceDefaultConfigDefinitions,
+ instanceIdentityDefaultDefinitions,
} from 'src/modules/default_config_state.js'
let staticInitialResults = null
const parsedInitialResults = () => {
if (!document.getElementById('initial-results')) {
return null
}
if (!staticInitialResults) {
staticInitialResults = JSON.parse(
document.getElementById('initial-results').textContent,
)
}
return staticInitialResults
}
const decodeUTF8Base64 = (data) => {
const rawData = atob(data)
const array = Uint8Array.from([...rawData].map((char) => char.charCodeAt(0)))
const text = new TextDecoder().decode(array)
return text
}
const preloadFetch = async (request) => {
const data = parsedInitialResults()
if (!data || !data[request]) {
return window.fetch(request)
}
const decoded = decodeUTF8Base64(data[request])
const requestData = JSON.parse(decoded)
return {
ok: true,
json: () => requestData,
text: () => requestData,
}
}
const getInstanceConfig = async ({ store }) => {
try {
const res = await preloadFetch('/api/v1/instance')
if (res.ok) {
const data = await res.json()
const textlimit = data.max_toot_chars
const vapidPublicKey = data.pleroma.vapid_public_key
useInstanceCapabilitiesStore().set(
'pleromaExtensionsAvailable',
data.pleroma,
)
useInstanceStore().set({
path: 'textlimit',
value: textlimit,
})
useInstanceStore().set({
path: 'accountApprovalRequired',
value: data.approval_required,
})
useInstanceStore().set({
path: 'birthdayRequired',
value: !!data.pleroma?.metadata.birthday_required,
})
useInstanceStore().set({
path: 'birthdayMinAge',
value: data.pleroma?.metadata.birthday_min_age || 0,
})
if (vapidPublicKey) {
useInstanceStore().set({
path: 'vapidPublicKey',
value: vapidPublicKey,
})
}
} else {
throw res
}
} catch (error) {
console.error('Could not load instance config, potentially fatal')
console.error(error)
}
// We should check for scrobbles support here but it requires userId
// so instead we check for it where it's fetched (statuses.js)
}
const getBackendProvidedConfig = async () => {
try {
const res = await window.fetch('/api/pleroma/frontend_configurations')
if (res.ok) {
const data = await res.json()
return data.pleroma_fe
} else {
throw res
}
} catch (error) {
console.error(
'Could not load backend-provided frontend config, potentially fatal',
)
console.error(error)
}
}
const getStaticConfig = async () => {
try {
const res = await window.fetch('/static/config.json')
if (res.ok) {
return res.json()
} else {
throw res
}
} catch (error) {
console.warn('Failed to load static/config.json, continuing without it.')
console.warn(error)
return {}
}
}
const setSettings = async ({ apiConfig, staticConfig, store }) => {
const overrides = window.___pleromafe_dev_overrides || {}
const env = window.___pleromafe_mode.NODE_ENV
// This takes static config and overrides properties that are present in apiConfig
let config = {}
if (overrides.staticConfigPreference && env === 'development') {
console.warn('OVERRIDING API CONFIG WITH STATIC CONFIG')
config = Object.assign({}, apiConfig, staticConfig)
} else {
config = Object.assign({}, staticConfig, apiConfig)
}
const copyInstanceOption = ({ source, definition = { required: true }, destination }) => {
const value = config[source]
- const { required, type } = definition
+ 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
useInstanceStore().set({ path: destination, value })
}
- Object.entries(instanceIdentityDefaultDefinition)
+ Object.entries(instanceIdentityDefaultDefinitions)
.map(([source, definition]) => ({ source, definition, destination: `instanceIdentity.${source}` }))
.forEach(copyInstanceOption)
- Object.keys(instanceDefaultConfig)
- .map((source) => ({ source, destination: `prefsStorage.${source}` }))
+ Object.keys(instanceDefaultConfigDefinitions)
+ .map(([source, definition]) => ({ source, definition, destination: `prefsStorage.${source}` }))
.forEach(copyInstanceOption)
useAuthFlowStore().setInitialStrategy(config.loginMethod)
}
const getTOS = async ({ store }) => {
try {
const res = await window.fetch('/static/terms-of-service.html')
if (res.ok) {
const html = await res.text()
useInstanceStore().set({ name: 'instanceIdentity.tos', value: html })
} else {
throw res
}
} catch (e) {
console.warn("Can't load TOS\n", e)
}
}
const getInstancePanel = async ({ store }) => {
try {
const res = await preloadFetch('/instance/panel.html')
if (res.ok) {
const html = await res.text()
useInstanceStore().set({
path: 'instanceIdentity.instanceSpecificPanelContent',
value: html,
})
} else {
throw res
}
} catch (e) {
console.warn("Can't load instance panel\n", e)
}
}
const getStickers = async ({ store }) => {
try {
const res = await window.fetch('/static/stickers.json')
if (res.ok) {
const values = await res.json()
const stickers = (
await Promise.all(
Object.entries(values).map(async ([name, path]) => {
const resPack = await window.fetch(path + 'pack.json')
let meta = {}
if (resPack.ok) {
meta = await resPack.json()
}
return {
pack: name,
path,
meta,
}
}),
)
).sort((a, b) => {
return a.meta.title.localeCompare(b.meta.title)
})
useEmojiStore().setStickers(stickers)
} else {
throw res
}
} catch (e) {
console.warn("Can't load stickers\n", e)
}
}
const getAppSecret = async ({ store }) => {
const oauth = useOAuthStore()
if (oauth.userToken) {
store.commit(
'setBackendInteractor',
backendInteractorService(oauth.getToken),
)
}
}
const resolveStaffAccounts = ({ store, accounts }) => {
const nicknames = accounts.map((uri) => uri.split('/').pop())
useInstanceStore().set({
path: 'staffAccounts',
value: nicknames,
})
}
const getNodeInfo = async ({ store }) => {
try {
let res = await preloadFetch('/nodeinfo/2.1.json')
if (!res.ok) res = await preloadFetch('/nodeinfo/2.0.json')
if (res.ok) {
const data = await res.json()
const metadata = data.metadata
const features = metadata.features
useInstanceStore().set({
path: 'name',
value: metadata.nodeName,
})
useInstanceStore().set({
path: 'registrationOpen',
value: data.openRegistrations,
})
useInstanceCapabilitiesStore().set(
'mediaProxyAvailable',
features.includes('media_proxy'),
)
useInstanceCapabilitiesStore().set(
'safeDM',
features.includes('safe_dm_mentions'),
)
useInstanceCapabilitiesStore().set(
'shoutAvailable',
features.includes('chat'),
)
useInstanceCapabilitiesStore().set(
'pleromaChatMessagesAvailable',
features.includes('pleroma_chat_messages'),
)
useInstanceCapabilitiesStore().set(
'pleromaCustomEmojiReactionsAvailable',
features.includes('pleroma_custom_emoji_reactions') ||
features.includes('custom_emoji_reactions'),
)
useInstanceCapabilitiesStore().set(
'pleromaBookmarkFoldersAvailable',
features.includes('pleroma:bookmark_folders'),
)
useInstanceCapabilitiesStore().set(
'gopherAvailable',
features.includes('gopher'),
)
useInstanceCapabilitiesStore().set(
'pollsAvailable',
features.includes('polls'),
)
useInstanceCapabilitiesStore().set(
'editingAvailable',
features.includes('editing'),
)
useInstanceCapabilitiesStore().set(
'mailerEnabled',
metadata.mailerEnabled,
)
useInstanceCapabilitiesStore().set(
'quotingAvailable',
features.includes('quote_posting'),
)
useInstanceCapabilitiesStore().set(
'groupActorAvailable',
features.includes('pleroma:group_actors'),
)
useInstanceCapabilitiesStore().set(
'blockExpiration',
features.includes('pleroma:block_expiration'),
)
useInstanceStore().set({
path: 'localBubbleInstances',
value: metadata.localBubbleInstances ?? [],
})
useInstanceCapabilitiesStore().set(
'localBubble',
(metadata.localBubbleInstances ?? []).length > 0,
)
useInstanceStore().set({
path: 'limits.pollLimits',
value: metadata.pollLimits,
})
const uploadLimits = metadata.uploadLimits
useInstanceStore().set({
path: 'limits.uploadlimit',
value: parseInt(uploadLimits.general),
})
useInstanceStore().set({
path: 'limits.avatarlimit',
value: parseInt(uploadLimits.avatar),
})
useInstanceStore().set({
path: 'limits.backgroundlimit',
value: parseInt(uploadLimits.background),
})
useInstanceStore().set({
path: 'limits.bannerlimit',
value: parseInt(uploadLimits.banner),
})
useInstanceStore().set({
path: 'limits.fieldsLimits',
value: metadata.fieldsLimits,
})
useInstanceStore().set({
path: 'restrictedNicknames',
value: metadata.restrictedNicknames,
})
useInstanceCapabilitiesStore().set('postFormats', metadata.postFormats)
const suggestions = metadata.suggestions
useInstanceCapabilitiesStore().set(
'suggestionsEnabled',
suggestions.enabled,
)
// this is unused, why?
useInstanceCapabilitiesStore().set('suggestionsWeb', suggestions.web)
const software = data.software
useInstanceStore().set({
path: 'backendVersion',
value: software.version,
})
useInstanceStore().set({
path: 'backendRepository',
value: software.repository,
})
const priv = metadata.private
useInstanceStore().set({ path: 'privateMode', value: priv })
const frontendVersion = window.___pleromafe_commit_hash
useInstanceStore().set({
path: 'frontendVersion',
value: frontendVersion,
})
const federation = metadata.federation
useInstanceCapabilitiesStore().set(
'tagPolicyAvailable',
typeof federation.mrf_policies === 'undefined'
? false
: metadata.federation.mrf_policies.includes('TagPolicy'),
)
useInstanceStore().set({
path: 'federationPolicy',
value: federation,
})
useInstanceStore().set({
path: 'federating',
value:
typeof federation.enabled === 'undefined' ? true : federation.enabled,
})
const accountActivationRequired = metadata.accountActivationRequired
useInstanceStore().set({
path: 'accountActivationRequired',
value: accountActivationRequired,
})
const accounts = metadata.staffAccounts
resolveStaffAccounts({ store, accounts })
} else {
throw res
}
} catch (e) {
console.warn('Could not load nodeinfo')
console.warn(e)
}
}
const setConfig = async ({ store }) => {
// apiConfig, staticConfig
const configInfos = await Promise.all([
getBackendProvidedConfig({ store }),
getStaticConfig(),
])
const apiConfig = configInfos[0]
const staticConfig = configInfos[1]
getAppSecret({ store })
await setSettings({ store, apiConfig, staticConfig })
}
const checkOAuthToken = async ({ store }) => {
const oauth = useOAuthStore()
if (oauth.getUserToken) {
return store.dispatch('loginUser', oauth.getUserToken)
}
return Promise.resolve()
}
const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
const app = createApp(App)
// Must have app use pinia before we do anything that touches the store
// https://pinia.vuejs.org/core-concepts/plugins.html#Introduction
// "Plugins are only applied to stores created after the plugins themselves, and after pinia is passed to the app, otherwise they won't be applied."
app.use(pinia)
const waitForAllStoresToLoad = async () => {
// the stores that do not persist technically do not need to be awaited here,
// but that involves either hard-coding the stores in some place (prone to errors)
// or writing another vite plugin to analyze which stores needs persisting (++load time)
const allStores = import.meta.glob('../stores/*.js', { eager: true })
if (process.env.NODE_ENV === 'development') {
// do some checks to avoid common errors
if (!Object.keys(allStores).length) {
throw new Error(
'No stores are available. Check the code in src/boot/after_store.js',
)
}
}
await Promise.all(
Object.entries(allStores).map(async ([name, mod]) => {
const isStoreName = (name) => name.startsWith('use')
if (process.env.NODE_ENV === 'development') {
if (Object.keys(mod).filter(isStoreName).length !== 1) {
throw new Error(
'Each store file must export exactly one store as a named export. Check your code in src/stores/',
)
}
}
const storeFuncName = Object.keys(mod).find(isStoreName)
if (storeFuncName && typeof mod[storeFuncName] === 'function') {
const p = mod[storeFuncName]().$persistLoaded
if (!(p instanceof Promise)) {
throw new Error(
`${name} store's $persistLoaded is not a Promise. The persist plugin is not applied.`,
)
}
await p
} else {
throw new Error(
`Store module ${name} does not export a 'use...' function`,
)
}
}),
)
}
try {
await waitForAllStoresToLoad()
} catch (e) {
console.error('Cannot load stores:', e)
storageError = e
}
if (storageError) {
useInterfaceStore().pushGlobalNotice({
messageKey: 'errors.storage_unavailable',
level: 'error',
})
}
useInterfaceStore().setLayoutWidth(windowWidth())
useInterfaceStore().setLayoutHeight(windowHeight())
window.syncConfig = useSyncConfigStore()
window.localConfig = useLocalConfigStore()
window.highlightConfig = useUserHighlightStore()
FaviconService.initFaviconService()
initServiceWorker(store)
window.addEventListener('focus', () => updateFocus())
const overrides = window.___pleromafe_dev_overrides || {}
const server =
typeof overrides.target !== 'undefined'
? overrides.target
: window.location.origin
useInstanceStore().set({ name: 'server', value: server })
await setConfig({ store })
try {
await useInterfaceStore()
.applyTheme()
.catch((e) => {
console.error('Error setting theme', e)
})
} catch (e) {
window.splashError(e)
return Promise.reject(e)
}
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
await Promise.all([
checkOAuthToken({ store }),
getInstancePanel({ store }),
getNodeInfo({ store }),
getInstanceConfig({ store }),
]).catch((e) => Promise.reject(e))
// Start fetching things that don't need to block the UI
store.dispatch('fetchMutes')
store.dispatch('loadDrafts')
useAnnouncementsStore().startFetchingAnnouncements()
getTOS({ store })
getStickers({ store })
const router = createRouter({
history: createWebHistory(),
routes: routes(store),
scrollBehavior: (to, _from, savedPosition) => {
if (to.matched.some((m) => m.meta.dontScroll)) {
return false
}
return savedPosition || { left: 0, top: 0 }
},
})
useI18nStore().setI18n(i18n)
app.use(router)
app.use(store)
app.use(i18n)
// Little thing to get out of invalid theme state
window.resetThemes = () => {
useInterfaceStore().resetThemeV3()
useInterfaceStore().resetThemeV3Palette()
useInterfaceStore().resetThemeV2()
}
app.use(vClickOutside)
app.use(VBodyScrollLock)
app.use(VueVirtualScroller)
app.component('FAIcon', FontAwesomeIcon)
app.component('FALayers', FontAwesomeLayers)
// remove after vue 3.3
app.config.unwrapInjectedRef = true
app.mount('#app')
return app
}
export default afterStoreSetup
diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js
index 79708430c7..89047f3148 100644
--- a/src/modules/default_config_state.js
+++ b/src/modules/default_config_state.js
@@ -1,304 +1,574 @@
const browserLocale = (navigator.language || 'en').split('-')[0]
+const convertDefinitions = definitions => Object.fromEntries(
+ Object.entries(definitions).map(([k, v]) => [
+ k,
+ v.default == null ? null : v.default,
+ ]),
+)
+
/// Instance config entries provided by static config or pleroma api
/// Put settings here only if it does not make sense for a normal user
/// to override it.
-export const instanceIdentityDefaultDefinition = {
+export const instanceIdentityDefaultDefinitions = {
style: {
description: 'Instance default style name',
type: 'string',
required: false,
},
palette: {
description: 'Instance default palette name',
type: 'string',
required: false,
},
theme: {
description: 'Instance default theme name',
type: 'string',
required: false,
},
defaultAvatar: {
description: "Default avatar image to use when user doesn't have one set",
type: 'string',
default: '/images/avi.png',
},
defaultBanner: {
description: "Default banner image to use when user doesn't have one set",
type: 'string',
default: '/images/banner.png',
},
background: {
description: 'Instance background/wallpaper',
type: 'string',
default: '/static/aurora_borealis.jpg',
},
embeddedToS: {
description: 'Whether to show Terms of Service title bar',
type: 'boolean',
default: true,
},
logo: {
description: 'Instance logo',
type: 'string',
default: '/static/logo.svg',
},
logoMargin: {
description: 'Margin for logo (spacing above/below)',
type: 'string',
default: '.2em',
},
logoMask: {
description:
'Use logo as a mask (works well for monochrome/transparent logos)',
type: 'boolean',
default: true,
},
logoLeft: {
description: 'Show logo on the left side of navbar',
type: 'boolean',
default: false,
},
redirectRootLogin: {
description: 'Where to redirect user after login',
type: 'string',
default: '/main/friends',
},
redirectRootNoLogin: {
description: 'Where to redirect anonymous visitors',
type: 'string',
default: '/main/all',
},
hideSitename: {
description: 'Hide the instance name in navbar',
type: 'boolean',
default: false,
},
nsfwCensorImage: {
description: 'Default NSFW censor image',
type: 'string',
required: false,
},
showFeaturesPanel: {
description: 'Show features panel to anonymous visitors',
type: 'boolean',
default: true,
},
showInstanceSpecificPanel: {
description: 'Show instance-specific panel',
type: 'boolean',
default: false,
},
// Html stuff
instanceSpecificPanelContent: {
description: 'HTML of Instance-specific panel',
type: 'string',
required: false,
},
tos: {
description: 'HTML of Terms of Service panel',
type: 'string',
required: false,
},
}
-export const instanceIdentityDefault = Object.fromEntries(
- Object.entries(instanceIdentityDefaultDefinition).map(([k, v]) => [
- k,
- v.default == null ? null : v.default,
- ]),
-)
+export const instanceIdentityDefault = convertDefinitions(instanceIdentityDefaultDefinitions)
/// This object contains setting entries that makes sense
/// at the user level. The defaults can also be overriden by
/// instance admins in the frontend_configuration endpoint or static config.
-export const instanceDefaultConfig = {
- expertLevel: 0, // used to track which settings to show and hide
- hideISP: false,
- hideInstanceWallpaper: false,
- hideShoutbox: false,
- // bad name: actually hides posts of muted USERS
- hideMutedPosts: false,
- hideMutedThreads: true,
- hideWordFilteredPosts: false,
- muteBotStatuses: false,
- muteSensitiveStatuses: false,
- collapseMessageWithSubject: false,
- padEmoji: true,
- hideAttachmentsInConv: false,
- hideScrobbles: false,
- hideScrobblesAfter: '2d',
- maxThumbnails: 16,
- loopVideo: true,
- loopVideoSilentOnly: true,
+export const instanceDefaultConfigDefinitions = {
+ expertLevel: {
+ description: 'Used to track which settings to show and hide in settings modal',
+ type: 'number', // not a boolean so we could potentially make multiple levels of expert-ness
+ default: 0,
+ },
+ hideISP: {
+ description: 'Hide Instance-specific panel',
+ default: false,
+ },
+ hideInstanceWallpaper: {
+ description: 'Hide Instance default background',
+ default: false,
+ },
+ hideShoutbox: {
+ description: 'Hide shoutbox if present',
+ default: false,
+ },
+ hideMutedPosts: { // bad name
+ description: 'Hide posts of muted users entirely',
+ default: false,
+ },
+ hideMutedThreads: {
+ description: 'Hide muted threads entirely',
+ default: true,
+ },
+ hideWordFilteredPosts: {
+ description: 'Hide wordfiltered posts entirely',
+ default: false,
+ },
+ muteBotStatuses: {
+ description: 'Mute posts made by bots',
+ default: false,
+ },
+ muteSensitiveStatuses: {
+ description: 'Mute posts marked as NSFW',
+ default: false,
+ },
+ collapseMessageWithSubject: {
+ description: 'Collapse posts with subject',
+ default: false,
+ },
+ padEmoji: {
+ description: 'Pad emoji with spaces when using emoji picker',
+ default: true,
+ },
+ hideAttachmentsInConv: {
+ description: 'Hide attachments',
+ default: false,
+ },
+ hideScrobbles: {
+ description: 'Hide scrobbles',
+ default: false,
+ },
+ hideScrobblesAfter: {
+ description: 'Hide scrobbles older than',
+ default: '2d',
+ },
+ maxThumbnails: {
+ description: 'Maximum attachments to show',
+ default: 16,
+ },
+ loopVideo: {
+ description: 'Loop videos',
+ default: true,
+ },
+ loopVideoSilentOnly: {
+ description: 'Loop only videos without sound',
+ default: true,
+ },
/// This is not the streaming API configuration, but rather an option
/// for automatically loading new posts into the timeline without
/// the user clicking the Show New button.
- streaming: false,
- emojiReactionsOnTimeline: true,
- alwaysShowNewPostButton: false,
- autohideFloatingPostButton: false,
- pauseOnUnfocused: true,
- stopGifs: true,
- replyVisibility: 'all',
- thirdColumnMode: 'notifications',
+ streaming: {
+ description: 'Automatically show new posts',
+ default: false,
+ },
+ pauseOnUnfocused: {
+ description: 'Pause showing new posts when tab is unfocused',
+ default: true,
+ },
+ emojiReactionsOnTimeline: {
+ description: 'Show emoji reactions on timeline',
+ default: true,
+ },
+ alwaysShowNewPostButton: {
+ description: 'Always show mobile "new post" button, even in desktop mode',
+ default: false,
+ },
+ autohideFloatingPostButton: {
+ description: 'Automatically hide mobile "new post" button when scrolling down',
+ default: false,
+ },
+ stopGifs: {
+ description: 'Play animated gifs on hover only',
+ default: true,
+ },
+ replyVisibility: {
+ description: 'Type of replies to show',
+ default: 'all',
+ },
+ thirdColumnMode: {
+ description: 'What to display in third column',
+ default: 'notifications',
+ },
notificationVisibility: {
- follows: true,
- mentions: true,
- statuses: true,
- likes: true,
- repeats: true,
- moves: true,
- emojiReactions: true,
- followRequest: true,
- reports: true,
- chatMention: true,
- polls: true,
+ description: 'What types of notifications to show',
+ default: {
+ follows: true,
+ mentions: true,
+ statuses: true,
+ likes: true,
+ repeats: true,
+ moves: true,
+ emojiReactions: true,
+ followRequest: true,
+ reports: true,
+ chatMention: true,
+ polls: true,
+ },
},
notificationNative: {
- follows: true,
- mentions: true,
- statuses: true,
- likes: false,
- repeats: false,
- moves: false,
- emojiReactions: false,
- followRequest: true,
- reports: true,
- chatMention: true,
- polls: true,
- },
- webPushNotifications: false,
- webPushAlwaysShowNotifications: false,
- interfaceLanguage: browserLocale,
- hideScopeNotice: false,
- scopeCopy: true,
- subjectLineBehavior: 'email',
- alwaysShowSubjectInput: true,
- minimalScopesMode: false,
+ description: 'What type of notifications to show desktop notification for',
+ default: {
+ follows: true,
+ mentions: true,
+ statuses: true,
+ likes: false,
+ repeats: false,
+ moves: false,
+ emojiReactions: false,
+ followRequest: true,
+ reports: true,
+ chatMention: true,
+ polls: true,
+ },
+ },
+ webPushNotifications: {
+ description: 'Use WebPush',
+ default: false,
+ },
+ webPushAlwaysShowNotifications: {
+ description: 'Ignore filter when using WebPush',
+ default: false,
+ },
+ interfaceLanguage: {
+ description: 'UI language',
+ default: browserLocale,
+ },
+ hideScopeNotice: {
+ description: 'Hide scope notification',
+ default: false,
+ },
+ scopeCopy: {
+ description: 'Copy scope like mastodon does',
+ default: true,
+ },
+ subjectLineBehavior: {
+ description: 'How to treat subject line',
+ default: 'email',
+ },
+ alwaysShowSubjectInput: {
+ description: 'Always show subject line field',
+ default: true,
+ },
+ minimalScopesMode: {
+ description: 'Minimize amount of options shown in scope selector',
+ default: false,
+ },
// This hides statuses filtered via a word filter
- hideFilteredStatuses: false,
+ hideFilteredStatuses: {
+ description: 'Hide wordfiltered entirely',
+ default: false,
+ },
// Confirmations
- modalOnRepeat: false,
- modalOnUnfollow: false,
- modalOnBlock: true,
- modalOnMute: false,
- modalOnMuteConversation: false,
- modalOnMuteDomain: true,
- modalOnDelete: true,
- modalOnLogout: true,
- modalOnApproveFollow: false,
- modalOnDenyFollow: false,
- modalOnRemoveUserFromFollowers: false,
+ modalOnRepeat: {
+ description: 'Show confirmation modal for repeat',
+ default: false,
+ },
+ modalOnUnfollow: {
+ description: 'Show confirmation modal for unfollow',
+ default: false,
+ },
+ modalOnBlock: {
+ description: 'Show confirmation modal for block',
+ default: true,
+ },
+ modalOnMute: {
+ description: 'Show confirmation modal for mute',
+ default: false,
+ },
+ modalOnMuteConversation: {
+ description: 'Show confirmation modal for mute conversation',
+ default: false,
+ },
+ modalOnMuteDomain: {
+ description: 'Show confirmation modal for mute domain',
+ default: true,
+ },
+ modalOnDelete: {
+ description: 'Show confirmation modal for delete',
+ default: true,
+ },
+ modalOnLogout: {
+ description: 'Show confirmation modal for logout',
+ default: true,
+ },
+ modalOnApproveFollow: {
+ description: 'Show confirmation modal for approve follow',
+ default: false,
+ },
+ modalOnDenyFollow: {
+ description: 'Show confirmation modal for deny follow',
+ default: false,
+ },
+ modalOnRemoveUserFromFollowers: {
+ description: 'Show confirmation modal for follower removal',
+ default: false,
+ },
// Expiry confirmations/default actions
- onMuteDefaultAction: 'ask',
- onBlockDefaultAction: 'ask',
+ onMuteDefaultAction: {
+ description: 'Default action when muting user',
+ default: 'ask',
+ },
+ onBlockDefaultAction: {
+ description: 'Default action when blocking user',
+ default: 'ask',
+ },
- modalMobileCenter: false,
- playVideosInModal: false,
- useContainFit: true,
- disableStickyHeaders: false,
- showScrollbars: false,
- userPopoverAvatarAction: 'open',
- userPopoverOverlay: false,
- userCardLeftJustify: false,
- userCardHidePersonalMarks: false,
- forcedRoundness: -1,
- greentext: false,
- mentionLinkShowTooltip: true,
- mentionLinkShowAvatar: false,
- mentionLinkFadeDomain: true,
- mentionLinkShowYous: false,
- mentionLinkBoldenYou: true,
- hidePostStats: false,
- hideBotIndication: false,
- hideUserStats: false,
- virtualScrolling: true,
- sensitiveByDefault: false,
- conversationDisplay: 'linear',
- conversationTreeAdvanced: false,
- conversationOtherRepliesButton: 'below',
- conversationTreeFadeAncestors: false,
- showExtraNotifications: true,
- showExtraNotificationsTip: true,
- showChatsInExtraNotifications: true,
- showAnnouncementsInExtraNotifications: true,
- showFollowRequestsInExtraNotifications: true,
- maxDepthInThread: 6,
- autocompleteSelect: false,
- closingDrawerMarksAsSeen: true,
- unseenAtTop: false,
- ignoreInactionableSeen: false,
- unsavedPostAction: 'confirm',
- autoSaveDraft: false,
- useAbsoluteTimeFormat: false,
- absoluteTimeFormatMinAge: '0d',
- absoluteTime12h: '24h',
+ modalMobileCenter: {
+ description: 'Center mobile dialogs vertically',
+ default: false,
+ },
+ playVideosInModal: {
+ description: 'Play videos in gallery view',
+ default: false,
+ },
+ useContainFit: {
+ description: 'Use object-fit: contain for attachments',
+ default: true,
+ },
+ disableStickyHeaders: {
+ description: 'Disable sticky headers',
+ default: false,
+ },
+ showScrollbars: {
+ description: 'Always show scrollbars',
+ default: false,
+ },
+ userPopoverAvatarAction: {
+ description: 'What to do when clicking popover avatar',
+ default: 'open',
+ },
+ userPopoverOverlay: {
+ description: 'Overlay user popover with centering on avatar',
+ default: false,
+ },
+ userCardLeftJustify: {
+ description: 'Justify user bio to the left',
+ default: false,
+ },
+ userCardHidePersonalMarks: {
+ description: 'Hide highlight/personal note in user view',
+ default: false,
+ },
+ forcedRoundness: {
+ description: 'Force roundness of the theme',
+ default: -1,
+ },
+ greentext: {
+ description: 'Highlight plaintext >quotes',
+ default: false,
+ },
+ mentionLinkShowTooltip: {
+ description: 'Show tooltips for mention links',
+ default: true,
+ },
+ mentionLinkShowAvatar: {
+ description: 'Show avatar next to mention link',
+ default: false,
+ },
+ mentionLinkFadeDomain: {
+ description: 'Mute (fade) domain name in mention links if configured to show it',
+ default: true,
+ },
+ mentionLinkShowYous: {
+ description: 'Show (you)s when you are mentioned',
+ default: false,
+ },
+ mentionLinkBoldenYou: {
+ description: 'Boldern mentionlink of you',
+ default: true,
+ },
+ hidePostStats: {
+ description: 'Hide post stats (rt, favs)',
+ default: false,
+ },
+ hideBotIndication: {
+ description: 'Hide bot indicator',
+ default: false,
+ },
+ hideUserStats: {
+ description: 'Hide user stats (followers etc)',
+ default: false,
+ },
+ virtualScrolling: {
+ description: 'Timeline virtual scrolling',
+ default: true,
+ },
+ sensitiveByDefault: {
+ description: 'Assume attachments are NSFW by default',
+ default: false,
+ },
+ conversationDisplay: {
+ description: 'Style of conversation display',
+ default: 'linear',
+ },
+ conversationTreeAdvanced: {
+ description: 'Advanced features of tree view conversation',
+ default: false,
+ },
+ conversationOtherRepliesButton: {
+ description: 'Where to show "other replies" in tree conversation view',
+ default: 'below',
+ },
+ conversationTreeFadeAncestors: {
+ description: 'Fade ancestors in tree conversation view',
+ default: false,
+ },
+ showExtraNotifications: {
+ description: 'Show extra notifications (chats, announcements etc) in notification panel',
+ default: true,
+ },
+ showExtraNotificationsTip: {
+ description: 'Show tip for extra notifications (that user can remove them)',
+ default: true,
+ },
+ showChatsInExtraNotifications: {
+ description: 'Show chat messages in notifications',
+ default: true,
+ },
+ showAnnouncementsInExtraNotifications: {
+ description: 'Show announcements in notifications',
+ default: true,
+ },
+ showFollowRequestsInExtraNotifications: {
+ description: 'Show follow requests in notifications',
+ default: true,
+ },
+ maxDepthInThread: {
+ description: 'Maximum depth in tree conversation view',
+ default: 6,
+ },
+ autocompleteSelect: {
+ description: '',
+ default: false,
+ },
+ closingDrawerMarksAsSeen: {
+ description: 'Closing mobile notification pane marks everything as seen',
+ default: true,
+ },
+ unseenAtTop: {
+ description: 'Show unseen notifications above others',
+ default: false,
+ },
+ ignoreInactionableSeen: {
+ description: 'Treat inactionable (fav, rt etc) notifications as "seen"',
+ default: false,
+ },
+ unsavedPostAction: {
+ description: 'What to do if post is aborted',
+ default: 'confirm',
+ },
+ autoSaveDraft: {
+ description: 'Save drafts automatically',
+ default: false,
+ },
+ useAbsoluteTimeFormat: {
+ description: 'Use absolute time format',
+ default: false,
+ },
+ absoluteTimeFormatMinAge: {
+ description: 'Show absolute time format only after this post age',
+ default: '0d',
+ },
+ absoluteTime12h: {
+ description: 'Use 24h time format',
+ default: '24h',
+ },
}
+export const instanceDefaultConfig = convertDefinitions(instanceDefaultConfigDefinitions)
export const defaultConfigLocal = {
hideAttachments: false,
hideAttachmentsInConv: false,
hideNsfw: true,
useOneClickNsfw: false,
preloadImage: true,
postContentType: 'text/plain',
sidebarRight: false,
sidebarColumnWidth: '25rem',
contentColumnWidth: '45rem',
notifsColumnWidth: '25rem',
themeEditorMinWidth: '0rem',
emojiReactionsScale: 0.5,
textSize: '1rem',
emojiSize: '2.2rem',
navbarSize: '3.5rem',
panelHeaderSize: '3.2rem',
navbarColumnStretch: false,
mentionLinkDisplay: 'short',
alwaysUseJpeg: false,
imageCompression: true,
useStreamingApi: false,
underlay: 'none',
fontInterface: undefined,
fontInput: undefined,
fontPosts: undefined,
fontMonospace: undefined,
themeDebug: false, // debug mode that uses computed backgrounds instead of real ones to debug contrast functions
forceThemeRecompilation: false, // flag that forces recompilation on boot even if cache exists
}
export const LOCAL_ONLY_KEYS = new Set(Object.keys(defaultConfigLocal))
export const makeUndefined = (c) =>
Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))
/// For properties with special processing or properties that does not
/// make sense to be overriden on a instance-wide level.
export const defaultState = {
// Set these to undefined so it does not interfere with default settings check
...makeUndefined(instanceDefaultConfig),
...makeUndefined(defaultConfigLocal),
// If there are any configurations that does not make sense to
// have instance-wide default, put it here and explain why.
// # Special processing
// ## Theme stuff
theme: undefined, // Very old theme store, stores preset name, still in use
// V1
colors: {}, // VERY old theme store, just colors of V1, probably not even used anymore
// V2
customTheme: undefined, // "snapshot", previously was used as actual theme store for V2 so it's still used in case of PleromaFE downgrade event.
customThemeSource: undefined, // "source", stores original theme data
// V3
style: null,
styleCustomData: null,
palette: null,
paletteCustomData: null,
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Nov 19, 3:20 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1840893
Default Alt Text
(38 KB)

Event Timeline