cleanup
This commit is contained in:
parent
d2c4bc3b2b
commit
30aae4a346
2 changed files with 2 additions and 62 deletions
|
|
@ -159,13 +159,6 @@ export const _getRecentData = (cache, live, isTest) => {
|
|||
}
|
||||
|
||||
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 {
|
||||
_user: a._user ?? b._user,
|
||||
_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
|
||||
: result.recent && merge(defaultState, result.recent)
|
||||
console.log('2',result.recent.prefsStorage.simple.conversationDisplay)
|
||||
|
||||
result.stale = isTest
|
||||
? result.stale
|
||||
: result.stale && merge(defaultState, result.stale)
|
||||
|
||||
console.log('3', result.recent.prefsStorage.simple.conversationDisplay)
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
@ -597,21 +586,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
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)
|
||||
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 flagsTemplate = userNew ? newUserFlags : defaultState.flagStorage
|
||||
|
|
|
|||
|
|
@ -123,30 +123,14 @@ describe('The SyncConfig module', () => {
|
|||
store.setPreference({ path: 'simple.testing', value: 1 })
|
||||
store.setPreference({ path: 'simple.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({
|
||||
path: 'collections.testing',
|
||||
value: 2,
|
||||
})
|
||||
store.removeCollectionPreference({
|
||||
path: 'objectCollections.testing',
|
||||
value: { _key: 'a' },
|
||||
})
|
||||
store.updateCache({ username: 'test' })
|
||||
expect(store.prefsStorage.simple.testing).to.eql(2)
|
||||
expect(store.prefsStorage.collections.testing).to.eql([])
|
||||
expect(store.prefsStorage.objectCollections.testing).to.eql({
|
||||
data: {},
|
||||
index: [],
|
||||
})
|
||||
expect(store.prefsStorage._journal.length).to.eql(3)
|
||||
expect(store.prefsStorage._journal.length).to.eql(2)
|
||||
expect(store.prefsStorage._journal[0]).to.eql({
|
||||
path: 'simple.testing',
|
||||
operation: 'set',
|
||||
|
|
@ -161,13 +145,6 @@ describe('The SyncConfig module', () => {
|
|||
// should have A timestamp, we don't really care what it is
|
||||
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', () => {
|
||||
|
|
@ -176,22 +153,10 @@ describe('The SyncConfig module', () => {
|
|||
store.setPreference({ path: 'simple.testing', value: 1 })
|
||||
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' })
|
||||
expect(store.prefsStorage.simple.testing).to.eql(1)
|
||||
expect(store.prefsStorage.collections.testing).to.eql([2])
|
||||
expect(store.prefsStorage.objectCollections.testing).to.eql({
|
||||
data: { a: { _key: 'a', foo: 1 } },
|
||||
index: ['a'],
|
||||
})
|
||||
expect(store.prefsStorage._journal.length).to.eql(4)
|
||||
expect(store.prefsStorage._journal.length).to.eql(2)
|
||||
})
|
||||
|
||||
it('should remove depth = 3 set/unset entries from journal', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue