Merge branch 'setttingssync' into shigusegubu-themes3
This commit is contained in:
commit
b1f3e097f4
7 changed files with 34 additions and 41 deletions
|
|
@ -10,6 +10,7 @@ import UnicodeDomainIndicator from '../unicode_domain_indicator/unicode_domain_i
|
|||
import UserAvatar from '../user_avatar/user_avatar.vue'
|
||||
|
||||
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'
|
||||
|
||||
|
|
@ -100,23 +101,23 @@ const MentionLink = {
|
|||
userNameFullUi() {
|
||||
return this.user && this.user.screen_name_ui
|
||||
},
|
||||
highlight() {
|
||||
return this.user && this.mergedConfig.highlight[this.user.screen_name]
|
||||
highlightData() {
|
||||
return this.highlight[this.user?.screen_name]
|
||||
},
|
||||
highlightType() {
|
||||
return this.highlight && '-' + this.highlight.type
|
||||
return this.highlightData && '-' + this.highlightData.type
|
||||
},
|
||||
highlightClass() {
|
||||
if (this.highlight) return highlightClass(this.user)
|
||||
return this.highlightData && highlightClass(this.user)
|
||||
},
|
||||
style() {
|
||||
if (this.highlight) {
|
||||
if (this.highlightData) {
|
||||
const {
|
||||
backgroundColor,
|
||||
backgroundPosition,
|
||||
backgroundImage,
|
||||
...rest
|
||||
} = highlightStyle(this.highlight)
|
||||
} = highlightStyle(this.highlightData)
|
||||
return rest
|
||||
}
|
||||
},
|
||||
|
|
@ -124,7 +125,7 @@ const MentionLink = {
|
|||
return [
|
||||
{
|
||||
'-you': this.isYou && this.shouldBoldenYou,
|
||||
'-highlighted': this.highlight,
|
||||
'-highlighted': !!this.highlightData,
|
||||
'-has-selection': this.hasSelection,
|
||||
},
|
||||
this.highlightType,
|
||||
|
|
@ -160,6 +161,7 @@ const MentionLink = {
|
|||
return this.mergedConfig.mentionLinkFadeDomain
|
||||
},
|
||||
...mapPiniaState(useSyncConfigStore, ['mergedConfig']),
|
||||
...mapPiniaState(useUserHighlightStore, ['highlight']),
|
||||
...mapState({
|
||||
currentUser: (state) => state.users.currentUser,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
|
|||
import Popover from '../popover/popover.vue'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import {
|
||||
LOCAL_ONLY_KEYS,
|
||||
useLocalConfigStore,
|
||||
} from 'src/stores/local_config.js'
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js'
|
||||
import {
|
||||
newExporter,
|
||||
newImporter,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const FilteringTab = {
|
|||
label: this.$t(`user_card.mute_block_${mode}`),
|
||||
})),
|
||||
muteFiltersDraftObject: cloneDeep(
|
||||
useSyncConfigStore().prefsStorage.simple.muteFilters,
|
||||
useSyncConfigStore().mergedConfig.muteFilters,
|
||||
),
|
||||
muteFiltersDraftDirty: Object.fromEntries(
|
||||
Object.entries(
|
||||
|
|
@ -259,9 +259,8 @@ const FilteringTab = {
|
|||
this.$store.dispatch('queueFlushAll')
|
||||
},
|
||||
muteFiltersObject() {
|
||||
console.log('UPDATE')
|
||||
this.muteFiltersDraftObject = cloneDeep(
|
||||
useSyncConfigStore().prefsStorage.simple.muteFilters,
|
||||
useSyncConfigStore().mergedConfig.muteFilters,
|
||||
)
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ export const defaultConfigLocal = {
|
|||
imageCompression: true,
|
||||
useStreamingApi: false,
|
||||
}
|
||||
export const LOCAL_ONLY_KEYS = new Set(Object.keys(defaultConfigLocal))
|
||||
|
||||
export const makeUndefined = (c) =>
|
||||
Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))
|
||||
|
|
|
|||
|
|
@ -350,7 +350,6 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
path: 'simple.styleCustomData',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
resetThemeV3Palette() {
|
||||
useSyncConfigStore().setPreference({
|
||||
|
|
@ -361,7 +360,6 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
path: 'simple.paletteCustomData',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
resetThemeV2() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.theme', value: null })
|
||||
|
|
@ -373,7 +371,6 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
path: 'simple.customThemeSource',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
async getThemeData() {
|
||||
const getData = async (resource, index, customData, name) => {
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ import { useInstanceStore } from 'src/stores/instance'
|
|||
|
||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||
|
||||
export const LOCAL_ONLY_KEYS = new Set(Object.keys(configDefaultState))
|
||||
|
||||
export const defaultState = {
|
||||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
import sum from 'hash-sum'
|
||||
import {
|
||||
merge as _merge,
|
||||
clamp,
|
||||
cloneDeep,
|
||||
debounce,
|
||||
findLastIndex,
|
||||
flatten,
|
||||
get,
|
||||
|
|
@ -18,16 +20,14 @@ import { toRaw } from 'vue'
|
|||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import {
|
||||
LOCAL_ONLY_KEYS,
|
||||
useLocalConfigStore,
|
||||
} from 'src/stores/local_config.js'
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import {
|
||||
defaultState as configDefaultState,
|
||||
defaultConfigLocal,
|
||||
instanceDefaultConfig,
|
||||
LOCAL_ONLY_KEYS,
|
||||
} from 'src/modules/default_config_state.js'
|
||||
import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ export const _resetFlags = (
|
|||
return result
|
||||
}
|
||||
|
||||
export const _resetPrefs = (
|
||||
const _resetPrefs = (
|
||||
totalPrefs,
|
||||
totalFlags,
|
||||
knownKeys = defaultState.flagStorage,
|
||||
|
|
@ -419,7 +419,7 @@ export const _resetPrefs = (
|
|||
return totalPrefs
|
||||
}
|
||||
|
||||
export const _doMigrations = async (data, setPreference) => {
|
||||
const _doMigrations = async (data, setPreference) => {
|
||||
if (data._version < VERSION) {
|
||||
console.debug(
|
||||
'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
|
||||
}
|
||||
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', {
|
||||
state() {
|
||||
|
|
@ -666,12 +678,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
// discarding timestamps and versions
|
||||
const { _timestamp: _0, _version: _1, ...recentData } = recent
|
||||
const { _timestamp: _2, _version: _3, ...staleData } = stale
|
||||
dirty = !isEqual(
|
||||
// Something wrong happens if we compare both objects directly
|
||||
// or with cloneDeep()
|
||||
JSON.parse(JSON.stringify(recentData)),
|
||||
JSON.parse(JSON.stringify(staleData)),
|
||||
)
|
||||
dirty = sum(recentData) !== sum(staleData)
|
||||
console.debug(`Data ${dirty ? 'needs' : "doesn't need"} merging`)
|
||||
}
|
||||
|
||||
|
|
@ -707,16 +714,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
this.pushSyncConfig()
|
||||
},
|
||||
pushSyncConfig({ force = false } = {}) {
|
||||
const needPush = this.dirty || force
|
||||
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
|
||||
})
|
||||
_pushSyncConfig(force, this)
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue