Merge branch 'setttingssync' into shigusegubu-themes3

This commit is contained in:
Henry Jameson 2026-02-23 19:30:44 +02:00
commit f70972d011
3 changed files with 4 additions and 64 deletions

View file

@ -36,11 +36,11 @@ const FilteringTab = {
label: this.$t(`user_card.mute_block_${mode}`), label: this.$t(`user_card.mute_block_${mode}`),
})), })),
muteFiltersDraftObject: cloneDeep( muteFiltersDraftObject: cloneDeep(
this.prefsStorage.simple.muteFilters, useSyncConfigStore().prefsStorage.simple.muteFilters,
), ),
muteFiltersDraftDirty: Object.fromEntries( muteFiltersDraftDirty: Object.fromEntries(
Object.entries( Object.entries(
this.prefsStorage.simple.muteFilters, useSyncConfigStore().prefsStorage.simple.muteFilters,
).map(([k]) => [k, false]), ).map(([k]) => [k, false]),
), ),
exportedFilter: null, exportedFilter: null,

View file

@ -159,13 +159,6 @@ export const _getRecentData = (cache, live, isTest) => {
} }
const merge = (a, b) => { const merge = (a, b) => {
console.log(
'MERGE',
a.prefsStorage.simple.conversationDisplay,
b.prefsStorage.simple.conversationDisplay,
)
console.log(a.prefsStorage.simple)
console.log(cloneDeep(a.prefsStorage).simple)
return { return {
_user: a._user ?? b._user, _user: a._user ?? b._user,
_version: a._version ?? b._version, _version: a._version ?? b._version,
@ -176,18 +169,14 @@ export const _getRecentData = (cache, live, isTest) => {
} }
} }
console.log('1',result.recent.prefsStorage.simple.conversationDisplay)
result.recent = isTest result.recent = isTest
? result.recent ? result.recent
: result.recent && merge(defaultState, result.recent) : result.recent && merge(defaultState, result.recent)
console.log('2',result.recent.prefsStorage.simple.conversationDisplay)
result.stale = isTest result.stale = isTest
? result.stale ? result.stale
: result.stale && merge(defaultState, result.stale) : result.stale && merge(defaultState, result.stale)
console.log('3', result.recent.prefsStorage.simple.conversationDisplay)
return result return result
} }
@ -597,21 +586,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
cache = null cache = null
} }
console.log('======')
console.log('CACHE', cache?.prefsStorage?.simple?.conversationDisplay)
console.log('LIVE', live?.prefsStorage?.simple?.conversationDisplay)
if (cache?._timestamp > live?._timestamp) {
console.log('C > L')
} else if (cache?._timestamp === live?._timestamp) {
console.log('C = L')
} else {
console.log('C < L')
}
let { recent, stale, needUpload } = _getRecentData(cache, live) let { recent, stale, needUpload } = _getRecentData(cache, live)
console.log('======')
console.log('RECENT', recent.prefsStorage?.simple?.conversationDisplay)
console.log('STALE', stale?.prefsStorage?.simple?.conversationDisplay)
console.log('======')
const userNew = userData.created_at > NEW_USER_DATE const userNew = userData.created_at > NEW_USER_DATE
const flagsTemplate = userNew ? newUserFlags : defaultState.flagStorage const flagsTemplate = userNew ? newUserFlags : defaultState.flagStorage

View file

@ -123,30 +123,14 @@ describe('The SyncConfig module', () => {
store.setPreference({ path: 'simple.testing', value: 1 }) store.setPreference({ path: 'simple.testing', value: 1 })
store.setPreference({ path: 'simple.testing', value: 2 }) store.setPreference({ path: 'simple.testing', value: 2 })
store.addCollectionPreference({ path: 'collections.testing', value: 2 }) store.addCollectionPreference({ path: 'collections.testing', value: 2 })
store.addCollectionPreference({
path: 'objectCollections.testing',
value: { _key: 'a', foo: 1 },
})
expect(store.prefsStorage.objectCollections.testing).to.eql({
data: { a: { _key: 'a', foo: 1 } },
index: ['a'],
})
store.removeCollectionPreference({ store.removeCollectionPreference({
path: 'collections.testing', path: 'collections.testing',
value: 2, value: 2,
}) })
store.removeCollectionPreference({
path: 'objectCollections.testing',
value: { _key: 'a' },
})
store.updateCache({ username: 'test' }) store.updateCache({ username: 'test' })
expect(store.prefsStorage.simple.testing).to.eql(2) expect(store.prefsStorage.simple.testing).to.eql(2)
expect(store.prefsStorage.collections.testing).to.eql([]) expect(store.prefsStorage.collections.testing).to.eql([])
expect(store.prefsStorage.objectCollections.testing).to.eql({ expect(store.prefsStorage._journal.length).to.eql(2)
data: {},
index: [],
})
expect(store.prefsStorage._journal.length).to.eql(3)
expect(store.prefsStorage._journal[0]).to.eql({ expect(store.prefsStorage._journal[0]).to.eql({
path: 'simple.testing', path: 'simple.testing',
operation: 'set', operation: 'set',
@ -161,13 +145,6 @@ describe('The SyncConfig module', () => {
// should have A timestamp, we don't really care what it is // should have A timestamp, we don't really care what it is
timestamp: store.prefsStorage._journal[1].timestamp, timestamp: store.prefsStorage._journal[1].timestamp,
}) })
expect(store.prefsStorage._journal[2]).to.eql({
path: 'objectCollections.testing',
operation: 'removeFromCollection',
args: [{ _key: 'a' }],
// should have A timestamp, we don't really care what it is
timestamp: store.prefsStorage._journal[2].timestamp,
})
}) })
it('should remove duplicate entries from journal', () => { it('should remove duplicate entries from journal', () => {
@ -176,22 +153,10 @@ describe('The SyncConfig module', () => {
store.setPreference({ path: 'simple.testing', value: 1 }) store.setPreference({ path: 'simple.testing', value: 1 })
store.addCollectionPreference({ path: 'collections.testing', value: 2 }) store.addCollectionPreference({ path: 'collections.testing', value: 2 })
store.addCollectionPreference({ path: 'collections.testing', value: 2 }) store.addCollectionPreference({ path: 'collections.testing', value: 2 })
store.addCollectionPreference({
path: 'objectCollections.testing',
value: { _key: 'a', foo: 1 },
})
store.addCollectionPreference({
path: 'objectCollections.testing',
value: { _key: 'a', foo: 1 },
})
store.updateCache({ username: 'test' }) store.updateCache({ username: 'test' })
expect(store.prefsStorage.simple.testing).to.eql(1) expect(store.prefsStorage.simple.testing).to.eql(1)
expect(store.prefsStorage.collections.testing).to.eql([2]) expect(store.prefsStorage.collections.testing).to.eql([2])
expect(store.prefsStorage.objectCollections.testing).to.eql({ expect(store.prefsStorage._journal.length).to.eql(2)
data: { a: { _key: 'a', foo: 1 } },
index: ['a'],
})
expect(store.prefsStorage._journal.length).to.eql(4)
}) })
it('should remove depth = 3 set/unset entries from journal', () => { it('should remove depth = 3 set/unset entries from journal', () => {