Merge branch 'setttingssync' into shigusegubu-themes3
This commit is contained in:
commit
42e5deb133
26 changed files with 157 additions and 58 deletions
14
src/App.js
14
src/App.js
|
|
@ -1,9 +1,6 @@
|
|||
import { throttle } from 'lodash'
|
||||
import { mapState } from 'pinia'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
import { mapGetters } from 'vuex'
|
||||
import messages from 'src/i18n/messages'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
|
||||
import DesktopNav from './components/desktop_nav/desktop_nav.vue'
|
||||
import EditStatusModal from './components/edit_status_modal/edit_status_modal.vue'
|
||||
|
|
@ -24,14 +21,17 @@ import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_pan
|
|||
import { getOrCreateServiceWorker } from './services/sw/sw'
|
||||
import { windowHeight, windowWidth } from './services/window_utils/window_utils'
|
||||
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
import { useEmojiStore } from 'src/stores/emoji.js'
|
||||
import { useI18nStore } from 'src/stores/i18n.js'
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useShoutStore } from 'src/stores/shout.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import messages from 'src/i18n/messages'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
|
||||
export default {
|
||||
name: 'app',
|
||||
components: {
|
||||
|
|
@ -142,7 +142,9 @@ export default {
|
|||
return this.currentUser.background_image
|
||||
},
|
||||
instanceBackground() {
|
||||
return useSyncConfigStore().mergedConfig.hideInstanceWallpaper ? null : this.instanceBackgroundUrl
|
||||
return useSyncConfigStore().mergedConfig.hideInstanceWallpaper
|
||||
? null
|
||||
: this.instanceBackgroundUrl
|
||||
},
|
||||
background() {
|
||||
return this.userBackground || this.instanceBackground
|
||||
|
|
@ -203,7 +205,7 @@ export default {
|
|||
!useSyncConfigStore().mergedConfig.hideISP
|
||||
)
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState(useInterfaceStore, [
|
||||
'themeApplied',
|
||||
'styleDataUsed',
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ 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'
|
||||
|
||||
|
|
@ -523,6 +524,8 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
|||
|
||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
||||
window.syncConfig = useSyncConfigStore()
|
||||
window.localConfig = useLocalConfigStore()
|
||||
|
||||
FaviconService.initFaviconService()
|
||||
initServiceWorker(store)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { mapGetters } from 'vuex'
|
||||
import { mapState } from 'pinia'
|
||||
|
||||
import nsfwImage from '../../assets/nsfw.png'
|
||||
import fileTypeService from '../../services/file_type/file_type.service.js'
|
||||
|
|
@ -140,7 +140,7 @@ const Attachment = {
|
|||
videoTag() {
|
||||
return this.useModal ? 'button' : 'span'
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
},
|
||||
watch: {
|
||||
'attachment.description'(newVal) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import UserAvatar from '../user_avatar/user_avatar.vue'
|
|||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import { faEllipsisH, faTimes } from '@fortawesome/free-solid-svg-icons'
|
||||
|
|
@ -85,7 +86,7 @@ const ChatMessage = {
|
|||
return { left: 50 }
|
||||
}
|
||||
},
|
||||
...mapGetters(['mergedConfig', 'findUser']),
|
||||
...mapPiniaState(useSyncConfigStore, ['mergedConfig', 'findUser']),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { clone, filter, findIndex, get, reduce } from 'lodash'
|
||||
import { mapState as mapPiniaState } from 'pinia'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
import { WSConnectionStatus } from '../../services/api/api.service.js'
|
||||
import QuickFilterSettings from '../quick_filter_settings/quick_filter_settings.vue'
|
||||
|
|
@ -393,7 +393,7 @@ const conversation = {
|
|||
maybeHighlight() {
|
||||
return this.isExpanded ? this.highlight : null
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState({
|
||||
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ const EmojiInput = {
|
|||
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)
|
||||
|
|
@ -165,7 +165,7 @@ const EmojiInput = {
|
|||
},
|
||||
languages() {
|
||||
return ensureFinalFallback(
|
||||
this.$store.getters.mergedConfig.interfaceLanguage,
|
||||
useSyncConfigStore().mergedConfig.interfaceLanguage,
|
||||
)
|
||||
},
|
||||
maybeLocalizedEmojiNamesAndKeywords() {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { mapGetters } from 'vuex'
|
|||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { mapState as mapPiniaState } from 'pinia'
|
||||
import { defineAsyncComponent } from 'vue'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
|
||||
|
|
@ -8,6 +9,8 @@ import {
|
|||
import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_indicator.vue'
|
||||
import UserAvatar from '../user_avatar/user_avatar.vue'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
|
|
@ -156,7 +159,7 @@ const MentionLink = {
|
|||
shouldFadeDomain() {
|
||||
return this.mergedConfig.mentionLinkFadeDomain
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState({
|
||||
currentUser: (state) => state.users.currentUser,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ const PostStatusForm = {
|
|||
)
|
||||
)
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState(useInterfaceStore, {
|
||||
mobileLayout: (store) => store.mobileLayout,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { mapState } from 'pinia'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
import Popover from '../popover/popover.vue'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import { faFilter, faFont, faWrench } from '@fortawesome/free-solid-svg-icons'
|
||||
|
|
@ -31,7 +31,7 @@ const QuickFilterSettings = {
|
|||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState(useInterfaceStore, {
|
||||
mobileLayout: (state) => state.layoutType === 'mobile',
|
||||
}),
|
||||
|
|
@ -87,7 +87,10 @@ const QuickFilterSettings = {
|
|||
},
|
||||
set() {
|
||||
const value = !this.hideMedia
|
||||
useSyncConfigStore().setSimplePrefAndSave({ path: 'hideAttachments', value })
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: 'hideAttachments',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: 'hideAttachmentsInConv',
|
||||
value,
|
||||
|
|
@ -112,7 +115,10 @@ const QuickFilterSettings = {
|
|||
},
|
||||
set() {
|
||||
const value = !this.muteBotStatuses
|
||||
useSyncConfigStore().setSimplePrefAndSave({ path: 'muteBotStatuses', value })
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: 'muteBotStatuses',
|
||||
value,
|
||||
})
|
||||
},
|
||||
},
|
||||
muteSensitiveStatuses: {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,10 @@ export default {
|
|||
const writePath = `simple.${readPath}`
|
||||
|
||||
if (!this.timedApplyMode) {
|
||||
useSyncConfigStore().setSimplePrefAndSave({ path: writePath, value })
|
||||
useSyncConfigStore().setSimplePrefAndSave({
|
||||
path: writePath,
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
} else {
|
||||
if (useInterfaceStore().temporaryChangesTimeoutId !== null) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
|
|||
import UnitSetting from '../helpers/unit_setting.vue'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import IntegerSetting from '../helpers/integer_setting.vue'
|
|||
import ProfileSettingIndicator from '../helpers/profile_setting_indicator.vue'
|
||||
import SharedComputedObject from '../helpers/shared_computed_object.js'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
const GeneralTab = {
|
||||
data() {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ import { useAnnouncementsStore } from 'src/stores/announcements'
|
|||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
import { useShoutStore } from 'src/stores/shout'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
|||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useReportsStore } from 'src/stores/reports.js'
|
||||
import { useStatusHistoryStore } from 'src/stores/statusHistory.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
const PRIVATE_SCOPES = new Set(['private', 'direct'])
|
||||
const PUBLIC_SCOPES = new Set(['public', 'unlisted'])
|
||||
|
|
@ -52,7 +53,7 @@ export const BUTTONS = [
|
|||
!PRIVATE_SCOPES.has(status.visibility)),
|
||||
toggleable: true,
|
||||
confirm: ({ status, getters }) =>
|
||||
!status.repeated && getters.mergedConfig.modalOnRepeat,
|
||||
!status.repeated && useSyncConfigStore().mergedConfig.modalOnRepeat,
|
||||
confirmStrings: {
|
||||
title: 'status.repeat_confirm_title',
|
||||
body: 'status.repeat_confirm',
|
||||
|
|
@ -227,7 +228,7 @@ export const BUTTONS = [
|
|||
currentUser.privileges.includes('messages_delete'))
|
||||
)
|
||||
},
|
||||
confirm: ({ getters }) => getters.mergedConfig.modalOnDelete,
|
||||
confirm: ({ getters }) => useSyncConfigStore().mergedConfig.modalOnDelete,
|
||||
confirmStrings: {
|
||||
title: 'status.delete_confirm_title',
|
||||
body: 'status.delete_confirm',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import { mapGetters } from 'vuex'
|
||||
import { mapState } from 'pinia'
|
||||
|
||||
import RichContent from 'src/components/rich_content/rich_content.jsx'
|
||||
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import fileType from 'src/services/file_type/file_type.service'
|
||||
|
||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||
|
|
@ -110,7 +112,7 @@ const StatusBody = {
|
|||
collapsedStatus() {
|
||||
return this.status.raw_html.replace(/(\n|<br\s?\/?>)/g, ' ')
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
},
|
||||
components: {
|
||||
RichContent,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { mapState as mapPiniaState } from 'pinia'
|
||||
import { mapGetters, mapState } from 'vuex'
|
||||
|
||||
import StatusBody from 'src/components/status_body/status_body.vue'
|
||||
|
|
@ -123,7 +124,7 @@ const StatusContent = {
|
|||
maxThumbnails() {
|
||||
return this.mergedConfig.maxThumbnails
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapState({
|
||||
currentUser: (state) => state.users.currentUser,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import * as DateUtils from 'src/services/date_utils/date_utils.js'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
|
||||
|
|
@ -13,17 +15,17 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
shouldUseAbsoluteTimeFormat() {
|
||||
if (!this.$store.getters.mergedConfig.useAbsoluteTimeFormat) {
|
||||
if (!useSyncConfigStore().mergedConfig.useAbsoluteTimeFormat) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
DateUtils.durationStrToMs(
|
||||
this.$store.getters.mergedConfig.absoluteTimeFormatMinAge,
|
||||
useSyncConfigStore().mergedConfig.absoluteTimeFormatMinAge,
|
||||
) <= this.relativeTimeMs
|
||||
)
|
||||
},
|
||||
time12hFormat() {
|
||||
return this.$store.getters.mergedConfig.absoluteTimeFormat12h === '12h'
|
||||
return useSyncConfigStore().mergedConfig.absoluteTimeFormat12h === '12h'
|
||||
},
|
||||
browserLocale() {
|
||||
return localeService.internalToBrowserLocale(this.$i18n.locale)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import isEqual from 'lodash/isEqual'
|
||||
import merge from 'lodash/merge'
|
||||
import ldUnescape from 'lodash/unescape'
|
||||
import { mapGetters } from 'vuex'
|
||||
import { mapState } from 'pinia'
|
||||
|
||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||
import ColorInput from 'src/components/color_input/color_input.vue'
|
||||
|
|
@ -243,7 +243,7 @@ export default {
|
|||
})
|
||||
}
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
},
|
||||
userHighlightColor: {
|
||||
get() {
|
||||
|
|
@ -391,7 +391,7 @@ export default {
|
|||
],
|
||||
})
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState(useSyncConfigStore, ['mergedConfig']),
|
||||
},
|
||||
methods: {
|
||||
muteUser() {
|
||||
|
|
|
|||
|
|
@ -682,7 +682,6 @@ const users = {
|
|||
useInterfaceStore().setLastTimeline('public-timeline')
|
||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
||||
//useSyncConfigStore().clearSyncConfig()
|
||||
})
|
||||
},
|
||||
loginUser(store, accessToken) {
|
||||
|
|
@ -780,7 +779,7 @@ const users = {
|
|||
dispatch('startFetchingFollowRequests')
|
||||
}
|
||||
|
||||
if (store.getters.mergedConfig.useStreamingApi) {
|
||||
if (useSyncConfigStore().mergedConfig.useStreamingApi) {
|
||||
dispatch('fetchTimeline', { timeline: 'friends', since: null })
|
||||
dispatch('fetchNotifications', { since: null })
|
||||
dispatch('enableMastoSockets', true)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { promiseInterval } from '../promise_interval/promise_interval.js'
|
|||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
const update = ({ store, notifications, older }) => {
|
||||
store.dispatch('addNewNotifications', { notifications, older })
|
||||
|
|
@ -26,10 +27,9 @@ const mastoApiNotificationTypes = new Set([
|
|||
|
||||
const fetchAndUpdate = ({ store, credentials, older = false, since }) => {
|
||||
const args = { credentials }
|
||||
const { getters } = store
|
||||
const rootState = store.rootState || store.state
|
||||
const timelineData = rootState.notifications
|
||||
const hideMutedPosts = getters.mergedConfig.hideMutedPosts
|
||||
const hideMutedPosts = useSyncConfigStore().mergedConfig.hideMutedPosts
|
||||
|
||||
if (useInstanceCapabilitiesStore().pleromaChatMessagesAvailable) {
|
||||
mastoApiNotificationTypes.add('pleroma:chat_mention')
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { promiseInterval } from '../promise_interval/promise_interval.js'
|
|||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
const update = ({
|
||||
store,
|
||||
|
|
@ -44,9 +45,8 @@ const fetchAndUpdate = ({
|
|||
}) => {
|
||||
const args = { timeline, credentials }
|
||||
const rootState = store.rootState || store.state
|
||||
const { getters } = store
|
||||
const timelineData = rootState.statuses.timelines[camelCase(timeline)]
|
||||
const { hideMutedPosts, replyVisibility } = getters.mergedConfig
|
||||
const { hideMutedPosts, replyVisibility } = useSyncConfigStore().mergedConfig
|
||||
const loggedIn = !!rootState.users.currentUser
|
||||
|
||||
if (older) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import Cookies from 'js-cookie'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import messages from 'src/i18n/messages'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
|
||||
|
||||
|
|
@ -21,6 +22,6 @@ export const useI18nStore = defineStore('i18n', {
|
|||
BACKEND_LANGUAGE_COOKIE_NAME,
|
||||
localeService.internalToBackendLocaleMulti(value),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
|
||||
const mobileLayout = width <= 800
|
||||
const normalOrMobile = mobileLayout ? 'mobile' : 'normal'
|
||||
const { thirdColumnMode } = window.vuex.getters.mergedConfig
|
||||
const { thirdColumnMode } = useSyncConfigStore().mergedConfig
|
||||
if (thirdColumnMode === 'none' || !window.vuex.state.users.currentUser) {
|
||||
this.layoutType = normalOrMobile
|
||||
} else {
|
||||
|
|
@ -252,7 +252,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV3Palette()
|
||||
this.resetThemeV2()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.paletteCustomData',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.applyTheme({ recompile: true })
|
||||
|
|
@ -292,7 +295,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV2()
|
||||
this.resetThemeV3Palette()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.styleCustomData',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.useStylePalette = true
|
||||
|
|
@ -330,18 +336,27 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV2()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customThemeSource',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.applyTheme({ recompile: true })
|
||||
},
|
||||
resetThemeV3() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.style', value: null })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.styleCustomData',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
resetThemeV3Palette() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.palette', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.palette',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.paletteCustomData',
|
||||
value: null,
|
||||
|
|
@ -350,7 +365,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
},
|
||||
resetThemeV2() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.theme', value: null })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customTheme',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customThemeSource',
|
||||
value: null,
|
||||
|
|
|
|||
50
src/stores/local_config.js
Normal file
50
src/stores/local_config.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import { cloneDeep, set } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
import { toRaw } from 'vue'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance'
|
||||
|
||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||
|
||||
export const defaultState = {
|
||||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
},
|
||||
}
|
||||
|
||||
export const useLocalConfigStore = defineStore('local_config', {
|
||||
state() {
|
||||
return cloneDeep(defaultState)
|
||||
},
|
||||
actions: {
|
||||
set({ path, value }) {
|
||||
set(this.prefsStorage, path, value)
|
||||
},
|
||||
unset({ path, value }) {
|
||||
set(this.prefsStorage, path, undefined)
|
||||
},
|
||||
clearSyncConfig() {
|
||||
const blankState = { ...cloneDeep(defaultState) }
|
||||
Object.keys(this).forEach((k) => {
|
||||
this.prefsStorage[k] = blankState[k]
|
||||
})
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
mergedConfig: (state) => {
|
||||
const instancePrefs = useInstanceStore().prefsStorage
|
||||
const result = Object.fromEntries(
|
||||
Object.entries(state.prefsStorage).map(([k, v]) => [
|
||||
k,
|
||||
v ?? instancePrefs[k],
|
||||
]),
|
||||
)
|
||||
return result
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
afterLoad(state) {
|
||||
return state
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
@ -97,14 +97,18 @@ const _verifyPrefs = (state) => {
|
|||
if (typeof v === 'undefined') return
|
||||
if (typeof v === 'number' || typeof v === 'boolean') return
|
||||
if (typeof v === 'object') return
|
||||
console.warn(`Preference simple.${k} as invalid type ${typeof v}, reinitializing`)
|
||||
console.warn(
|
||||
`Preference simple.${k} as invalid type ${typeof v}, reinitializing`,
|
||||
)
|
||||
set(state.prefsStorage.simple, k, defaultState.prefsStorage.simple[k])
|
||||
})
|
||||
|
||||
// Collections
|
||||
Object.entries(defaultState.prefsStorage.collections).forEach(([k, v]) => {
|
||||
if (Array.isArray(v)) return
|
||||
console.warn(`Preference collections.${k} as invalid type ${typeof v}, reinitializing`)
|
||||
console.warn(
|
||||
`Preference collections.${k} as invalid type ${typeof v}, reinitializing`,
|
||||
)
|
||||
set(
|
||||
state.prefsStorage.collections,
|
||||
k,
|
||||
|
|
@ -306,7 +310,9 @@ export const _mergePrefs = (recent, stale) => {
|
|||
break
|
||||
case 'addToCollection':
|
||||
if (!path.startsWith('collections')) {
|
||||
return console.error('Illegal operation "addToCollection" on a non-collection')
|
||||
return console.error(
|
||||
'Illegal operation "addToCollection" on a non-collection',
|
||||
)
|
||||
}
|
||||
set(
|
||||
resultOutput,
|
||||
|
|
@ -316,7 +322,9 @@ export const _mergePrefs = (recent, stale) => {
|
|||
break
|
||||
case 'removeFromCollection': {
|
||||
if (!path.startsWith('collections')) {
|
||||
return console.error('Illegal operation "removeFromCollection" on a non-collection')
|
||||
return console.error(
|
||||
'Illegal operation "removeFromCollection" on a non-collection',
|
||||
)
|
||||
}
|
||||
const newSet = new Set(get(resultOutput, path))
|
||||
newSet.delete(args[0])
|
||||
|
|
@ -438,9 +446,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
`Tried to edit internal (starts with _) field '${path}', ignoring.`,
|
||||
)
|
||||
}
|
||||
if (
|
||||
path.startsWith('collections')
|
||||
) {
|
||||
if (path.startsWith('collections')) {
|
||||
throw new Error(
|
||||
`Invalid operation 'set' for collection field '${path}', ignoring.`,
|
||||
)
|
||||
|
|
@ -468,9 +474,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
`Tried to edit internal (starts with _) field '${path}', ignoring.`,
|
||||
)
|
||||
}
|
||||
if (
|
||||
path.startsWith('collections')
|
||||
) {
|
||||
if (path.startsWith('collections')) {
|
||||
throw new Error(
|
||||
`Invalid operation 'unset' for collection field '${path}', ignoring.`,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue