Merge branch 'setttingssync' into shigusegubu-themes3

This commit is contained in:
Henry Jameson 2026-03-16 20:22:50 +02:00
commit b1f3e097f4
7 changed files with 34 additions and 41 deletions

View file

@ -10,6 +10,7 @@ import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_i
import UserAvatar from '../user_avatar/user_avatar.vue' import UserAvatar from '../user_avatar/user_avatar.vue'
import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator' import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
@ -100,23 +101,23 @@ const MentionLink = {
userNameFullUi() { userNameFullUi() {
return this.user && this.user.screen_name_ui return this.user && this.user.screen_name_ui
}, },
highlight() { highlightData() {
return this.user && this.mergedConfig.highlight[this.user.screen_name] return this.highlight[this.user?.screen_name]
}, },
highlightType() { highlightType() {
return this.highlight && '-' + this.highlight.type return this.highlightData && '-' + this.highlightData.type
}, },
highlightClass() { highlightClass() {
if (this.highlight) return highlightClass(this.user) return this.highlightData && highlightClass(this.user)
}, },
style() { style() {
if (this.highlight) { if (this.highlightData) {
const { const {
backgroundColor, backgroundColor,
backgroundPosition, backgroundPosition,
backgroundImage, backgroundImage,
...rest ...rest
} = highlightStyle(this.highlight) } = highlightStyle(this.highlightData)
return rest return rest
} }
}, },
@ -124,7 +125,7 @@ const MentionLink = {
return [ return [
{ {
'-you': this.isYou && this.shouldBoldenYou, '-you': this.isYou && this.shouldBoldenYou,
'-highlighted': this.highlight, '-highlighted': !!this.highlightData,
'-has-selection': this.hasSelection, '-has-selection': this.hasSelection,
}, },
this.highlightType, this.highlightType,
@ -160,6 +161,7 @@ const MentionLink = {
return this.mergedConfig.mentionLinkFadeDomain return this.mergedConfig.mentionLinkFadeDomain
}, },
...mapPiniaState(useSyncConfigStore, ['mergedConfig']), ...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
...mapPiniaState(useUserHighlightStore, ['highlight']),
...mapState({ ...mapState({
currentUser: (state) => state.users.currentUser, currentUser: (state) => state.users.currentUser,
}), }),

View file

@ -9,12 +9,10 @@ import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
import Popover from '../popover/popover.vue' import Popover from '../popover/popover.vue'
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
import { import { useLocalConfigStore } from 'src/stores/local_config.js'
LOCAL_ONLY_KEYS,
useLocalConfigStore,
} from 'src/stores/local_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js'
import { import {
newExporter, newExporter,
newImporter, newImporter,

View file

@ -36,7 +36,7 @@ const FilteringTab = {
label: this.$t(`user_card.mute_block_${mode}`), label: this.$t(`user_card.mute_block_${mode}`),
})), })),
muteFiltersDraftObject: cloneDeep( muteFiltersDraftObject: cloneDeep(
useSyncConfigStore().prefsStorage.simple.muteFilters, useSyncConfigStore().mergedConfig.muteFilters,
), ),
muteFiltersDraftDirty: Object.fromEntries( muteFiltersDraftDirty: Object.fromEntries(
Object.entries( Object.entries(
@ -259,9 +259,8 @@ const FilteringTab = {
this.$store.dispatch('queueFlushAll') this.$store.dispatch('queueFlushAll')
}, },
muteFiltersObject() { muteFiltersObject() {
console.log('UPDATE')
this.muteFiltersDraftObject = cloneDeep( this.muteFiltersDraftObject = cloneDeep(
useSyncConfigStore().prefsStorage.simple.muteFilters, useSyncConfigStore().mergedConfig.muteFilters,
) )
}, },
}, },

View file

@ -182,6 +182,7 @@ export const defaultConfigLocal = {
imageCompression: true, imageCompression: true,
useStreamingApi: false, useStreamingApi: false,
} }
export const LOCAL_ONLY_KEYS = new Set(Object.keys(defaultConfigLocal))
export const makeUndefined = (c) => export const makeUndefined = (c) =>
Object.fromEntries(Object.keys(c).map((key) => [key, undefined])) Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))

View file

@ -350,7 +350,6 @@ export const useInterfaceStore = defineStore('interface', {
path: 'simple.styleCustomData', path: 'simple.styleCustomData',
value: null, value: null,
}) })
useSyncConfigStore().pushSyncConfig()
}, },
resetThemeV3Palette() { resetThemeV3Palette() {
useSyncConfigStore().setPreference({ useSyncConfigStore().setPreference({
@ -361,7 +360,6 @@ export const useInterfaceStore = defineStore('interface', {
path: 'simple.paletteCustomData', path: 'simple.paletteCustomData',
value: null, value: null,
}) })
useSyncConfigStore().pushSyncConfig()
}, },
resetThemeV2() { resetThemeV2() {
useSyncConfigStore().setPreference({ path: 'simple.theme', value: null }) useSyncConfigStore().setPreference({ path: 'simple.theme', value: null })
@ -373,7 +371,6 @@ export const useInterfaceStore = defineStore('interface', {
path: 'simple.customThemeSource', path: 'simple.customThemeSource',
value: null, value: null,
}) })
useSyncConfigStore().pushSyncConfig()
}, },
async getThemeData() { async getThemeData() {
const getData = async (resource, index, customData, name) => { const getData = async (resource, index, customData, name) => {

View file

@ -6,8 +6,6 @@ import { useInstanceStore } from 'src/stores/instance'
import { defaultState as configDefaultState } from 'src/modules/default_config_state' import { defaultState as configDefaultState } from 'src/modules/default_config_state'
export const LOCAL_ONLY_KEYS = new Set(Object.keys(configDefaultState))
export const defaultState = { export const defaultState = {
prefsStorage: { prefsStorage: {
...configDefaultState, ...configDefaultState,

View file

@ -1,7 +1,9 @@
import sum from 'hash-sum'
import { import {
merge as _merge, merge as _merge,
clamp, clamp,
cloneDeep, cloneDeep,
debounce,
findLastIndex, findLastIndex,
flatten, flatten,
get, get,
@ -18,16 +20,14 @@ import { toRaw } from 'vue'
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js' import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
import { import { useLocalConfigStore } from 'src/stores/local_config.js'
LOCAL_ONLY_KEYS,
useLocalConfigStore,
} from 'src/stores/local_config.js'
import { storage } from 'src/lib/storage.js' import { storage } from 'src/lib/storage.js'
import { import {
defaultState as configDefaultState, defaultState as configDefaultState,
defaultConfigLocal, defaultConfigLocal,
instanceDefaultConfig, instanceDefaultConfig,
LOCAL_ONLY_KEYS,
} from 'src/modules/default_config_state.js' } from 'src/modules/default_config_state.js'
import { defaultConfigSync } from 'src/modules/old_default_config_state.js' import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
@ -395,7 +395,7 @@ export const _resetFlags = (
return result return result
} }
export const _resetPrefs = ( const _resetPrefs = (
totalPrefs, totalPrefs,
totalFlags, totalFlags,
knownKeys = defaultState.flagStorage, knownKeys = defaultState.flagStorage,
@ -419,7 +419,7 @@ export const _resetPrefs = (
return totalPrefs return totalPrefs
} }
export const _doMigrations = async (data, setPreference) => { const _doMigrations = async (data, setPreference) => {
if (data._version < VERSION) { if (data._version < VERSION) {
console.debug( console.debug(
'Data has older version, seeing if there any migrations that can be applied', 'Data has older version, seeing if there any migrations that can be applied',
@ -447,6 +447,18 @@ export const _doMigrations = async (data, setPreference) => {
return data return data
} }
const _pushSyncConfig = debounce((force, root) => {
const needPush = root.dirty || force
if (!needPush) return
root.updateCache({ username: window.vuex.state.users.currentUser.fqn })
const params = { pleroma_settings_store: { 'pleroma-fe': root.cache } }
window.vuex.state.api.backendInteractor
.updateProfileJSON({ params })
.then((user) => {
root.initSyncConfig(user)
root.dirty = false
})
}, 5000)
export const useSyncConfigStore = defineStore('sync_config', { export const useSyncConfigStore = defineStore('sync_config', {
state() { state() {
@ -666,12 +678,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
// discarding timestamps and versions // discarding timestamps and versions
const { _timestamp: _0, _version: _1, ...recentData } = recent const { _timestamp: _0, _version: _1, ...recentData } = recent
const { _timestamp: _2, _version: _3, ...staleData } = stale const { _timestamp: _2, _version: _3, ...staleData } = stale
dirty = !isEqual( dirty = sum(recentData) !== sum(staleData)
// Something wrong happens if we compare both objects directly
// or with cloneDeep()
JSON.parse(JSON.stringify(recentData)),
JSON.parse(JSON.stringify(staleData)),
)
console.debug(`Data ${dirty ? 'needs' : "doesn't need"} merging`) console.debug(`Data ${dirty ? 'needs' : "doesn't need"} merging`)
} }
@ -707,16 +714,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
this.pushSyncConfig() this.pushSyncConfig()
}, },
pushSyncConfig({ force = false } = {}) { pushSyncConfig({ force = false } = {}) {
const needPush = this.dirty || force _pushSyncConfig(force, this)
if (!needPush) return
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
const params = { pleroma_settings_store: { 'pleroma-fe': this.cache } }
window.vuex.state.api.backendInteractor
.updateProfileJSON({ params })
.then((user) => {
this.initSyncConfig(user)
this.dirty = false
})
}, },
}, },
getters: { getters: {