work on local-only settings
This commit is contained in:
parent
24be3da17e
commit
449c244d11
6 changed files with 35 additions and 32 deletions
|
|
@ -7,6 +7,7 @@ import ProfileSettingIndicator from './profile_setting_indicator.vue'
|
||||||
import { useInstanceStore } from 'src/stores/instance.js'
|
import { useInstanceStore } from 'src/stores/instance.js'
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
:units="['px', 'rem']"
|
:units="['px', 'rem']"
|
||||||
:reset-default="{ 'px': 14, 'rem': 1 }"
|
:reset-default="{ 'px': 14, 'rem': 1 }"
|
||||||
timed-apply-mode
|
timed-apply-mode
|
||||||
|
:local="true"
|
||||||
>
|
>
|
||||||
{{ $t('settings.text_size') }}
|
{{ $t('settings.text_size') }}
|
||||||
</UnitSetting>
|
</UnitSetting>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,39 @@
|
||||||
import { applyStyleConfig } from 'src/services/style_setter/style_setter.js'
|
import { applyStyleConfig } from 'src/services/style_setter/style_setter.js'
|
||||||
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
|
||||||
const APPEARANCE_SETTINGS_KEYS = new Set(
|
const ACTIONS = new Set([
|
||||||
[
|
'setPreference',
|
||||||
'sidebarColumnWidth',
|
'unsetPreference',
|
||||||
'contentColumnWidth',
|
'set',
|
||||||
'notifsColumnWidth',
|
'unset',
|
||||||
'themeEditorMinWidth',
|
'setTemporarily',
|
||||||
'textSize',
|
'unsetTemporarily',
|
||||||
'navbarSize',
|
])
|
||||||
'panelHeaderSize',
|
|
||||||
'forcedRoundness',
|
const APPEARANCE_SETTINGS_KEYS = [
|
||||||
'emojiSize',
|
'sidebarColumnWidth',
|
||||||
'emojiReactionsScale',
|
'contentColumnWidth',
|
||||||
].map((x) => 'simple.' + x),
|
'notifsColumnWidth',
|
||||||
)
|
'themeEditorMinWidth',
|
||||||
|
'textSize',
|
||||||
|
'navbarSize',
|
||||||
|
'panelHeaderSize',
|
||||||
|
'forcedRoundness',
|
||||||
|
'emojiSize',
|
||||||
|
'emojiReactionsScale',
|
||||||
|
]
|
||||||
|
const MIXED_KEYS = new Set([
|
||||||
|
...APPEARANCE_SETTINGS_KEYS,
|
||||||
|
...APPEARANCE_SETTINGS_KEYS.map((x) => 'simple.' + x),
|
||||||
|
])
|
||||||
|
|
||||||
export const piniaStylePlugin = ({ store, options }) => {
|
export const piniaStylePlugin = ({ store, options }) => {
|
||||||
if (store.$id === 'sync_config') {
|
if (store.$id === 'sync_config' || store.$id === 'local_config') {
|
||||||
store.$onAction(({ name, args, after }) => {
|
store.$onAction(({ name, args, after }) => {
|
||||||
if (name === 'setPreference') {
|
if (ACTIONS.has(name)) {
|
||||||
const { path } = args[0]
|
const { path } = args[0]
|
||||||
if (APPEARANCE_SETTINGS_KEYS.has(path)) {
|
if (MIXED_KEYS.has(path)) {
|
||||||
after(() => applyStyleConfig(store.mergedConfig))
|
after(() => applyStyleConfig(useSyncConfigStore().mergedConfig))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export const useInterfaceStore = defineStore('interface', {
|
||||||
this.temporaryChangesConfirm = confirm
|
this.temporaryChangesConfirm = confirm
|
||||||
this.temporaryChangesRevert = revert
|
this.temporaryChangesRevert = revert
|
||||||
const countdownFunc = () => {
|
const countdownFunc = () => {
|
||||||
if (this.temporaryChangesCountdown === 1) {
|
if (this.temporaryChangesCountdown <= 1) {
|
||||||
this.temporaryChangesRevert()
|
this.temporaryChangesRevert()
|
||||||
this.clearTemporaryChanges()
|
this.clearTemporaryChanges()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -39,18 +39,6 @@ export const useLocalConfigStore = defineStore('local_config', {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
getters: {
|
|
||||||
mergedConfig: (state) => {
|
|
||||||
const instancePrefs = useInstanceStore().prefsStorage
|
|
||||||
const result = Object.fromEntries(
|
|
||||||
Object.entries(state.prefsStorage).map(([k, v]) => [
|
|
||||||
k,
|
|
||||||
state.tempStorage[k] ?? v ?? instancePrefs[k],
|
|
||||||
]),
|
|
||||||
)
|
|
||||||
return result
|
|
||||||
},
|
|
||||||
},
|
|
||||||
persist: {
|
persist: {
|
||||||
afterLoad(state) {
|
afterLoad(state) {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -691,10 +691,11 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
mergedConfig: (state) => {
|
mergedConfig: (state) => {
|
||||||
const instancePrefs = useInstanceStore().prefsStorage
|
const instancePrefs = useInstanceStore().prefsStorage
|
||||||
const localPrefs = useLocalConfigStore().prefsStorage
|
const localPrefs = useLocalConfigStore().prefsStorage
|
||||||
|
const tempPrefs = useLocalConfigStore().tempStorage
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
Object.entries(state.prefsStorage.simple).map(([k, v]) => [
|
Object.entries(state.prefsStorage.simple).map(([k, v]) => [
|
||||||
k,
|
k,
|
||||||
localPrefs[k] ?? v ?? instancePrefs[k],
|
tempPrefs[k] ?? localPrefs[k] ?? v ?? instancePrefs[k],
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue