f0c4bb1193
* upstream/develop: (33 commits) add emoji reactions to changelog fix emoji reaction classes broken in develop review changes Fix password and email update remove unnecessary anonymous function Apply suggestion to src/services/api/api.service.js remove logs/commented code remove favs count from react button remove mock data change emoji reactions to use new format Added polyfills for EventTarget (needed for Safari) and CustomEvent (needed for IE) Fix missing TWKN when logged in, but server is set to private mode. Fix follower request fetching Add domain mutes to changelog Implement domain mutes v2 change changelog to reflect actual release history of frontend Fix #750 , fix error messages and captcha resetting Optimize Notifications Rendering update CHANGELOG Use last seen notif instead of first unseen notif for sinceId ...
110 lines
3.1 KiB
JavaScript
110 lines
3.1 KiB
JavaScript
import { set, delete as del } from 'vue'
|
|
import { setPreset, applyTheme } from '../services/style_setter/style_setter.js'
|
|
|
|
const browserLocale = (window.navigator.language || 'en').split('-')[0]
|
|
|
|
export const defaultState = {
|
|
colors: {},
|
|
theme: undefined,
|
|
customTheme: undefined,
|
|
customThemeSource: undefined,
|
|
hideISP: false,
|
|
// bad name: actually hides posts of muted USERS
|
|
hideMutedPosts: undefined, // instance default
|
|
collapseMessageWithSubject: undefined, // instance default
|
|
padEmoji: true,
|
|
hideAttachments: false,
|
|
hideAttachmentsInConv: false,
|
|
maxThumbnails: 16,
|
|
hideNsfw: true,
|
|
preloadImage: true,
|
|
loopVideo: true,
|
|
loopVideoSilentOnly: true,
|
|
autoLoad: true,
|
|
streaming: false,
|
|
hoverPreview: true,
|
|
autohideFloatingPostButton: false,
|
|
pauseOnUnfocused: true,
|
|
stopGifs: false,
|
|
replyVisibility: 'all',
|
|
notificationVisibility: {
|
|
follows: true,
|
|
mentions: true,
|
|
likes: true,
|
|
repeats: true,
|
|
moves: true
|
|
},
|
|
webPushNotifications: false,
|
|
muteWords: [],
|
|
highlight: {},
|
|
interfaceLanguage: browserLocale,
|
|
hideScopeNotice: false,
|
|
useStreamingApi: false,
|
|
scopeCopy: undefined, // instance default
|
|
subjectLineBehavior: undefined, // instance default
|
|
alwaysShowSubjectInput: undefined, // instance default
|
|
postContentType: undefined, // instance default
|
|
minimalScopesMode: undefined, // instance default
|
|
// This hides statuses filtered via a word filter
|
|
hideFilteredStatuses: undefined, // instance default
|
|
playVideosInModal: false,
|
|
useOneClickNsfw: false,
|
|
useContainFit: false,
|
|
greentext: undefined, // instance default
|
|
hidePostStats: undefined, // instance default
|
|
hideUserStats: undefined // instance default
|
|
}
|
|
|
|
// caching the instance default properties
|
|
export const instanceDefaultProperties = Object.entries(defaultState)
|
|
.filter(([key, value]) => value === undefined)
|
|
.map(([key, value]) => key)
|
|
|
|
const config = {
|
|
state: defaultState,
|
|
getters: {
|
|
mergedConfig (state, getters, rootState, rootGetters) {
|
|
const { instance } = rootState
|
|
return {
|
|
...state,
|
|
...instanceDefaultProperties
|
|
.map(key => [key, state[key] === undefined
|
|
? instance[key]
|
|
: state[key]
|
|
])
|
|
.reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {})
|
|
}
|
|
}
|
|
},
|
|
mutations: {
|
|
setOption (state, { name, value }) {
|
|
set(state, name, value)
|
|
},
|
|
setHighlight (state, { user, color, type }) {
|
|
const data = this.state.config.highlight[user]
|
|
if (color || type) {
|
|
set(state.highlight, user, { color: color || data.color, type: type || data.type })
|
|
} else {
|
|
del(state.highlight, user)
|
|
}
|
|
}
|
|
},
|
|
actions: {
|
|
setHighlight ({ commit, dispatch }, { user, color, type }) {
|
|
commit('setHighlight', { user, color, type })
|
|
},
|
|
setOption ({ commit, dispatch }, { name, value }) {
|
|
commit('setOption', { name, value })
|
|
switch (name) {
|
|
case 'theme':
|
|
setPreset(value)
|
|
break
|
|
case 'customTheme':
|
|
applyTheme(value)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export default config
|