use json-clone to compare recent and stale data
This commit is contained in:
parent
3121eaad01
commit
6659308ace
1 changed files with 8 additions and 3 deletions
|
|
@ -630,10 +630,10 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
const different = !isEqual(oldValue, defaultValue)
|
const different = !isEqual(oldValue, defaultValue)
|
||||||
|
|
||||||
if (present && !migrated && different) {
|
if (present && !migrated && different) {
|
||||||
|
console.debug(`Migrating config ${key}: ${oldValue}`,)
|
||||||
this.setPreference({ path: `simple.${key}`, oldValue })
|
this.setPreference({ path: `simple.${key}`, oldValue })
|
||||||
migratedEntries.add(key)
|
migratedEntries.add(key)
|
||||||
this.needUpload = true
|
needUpload = true
|
||||||
console.debug(`Migrating config ${key}: ${oldValue}`,)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
vuexState.config._syncMigration = [...migratedEntries]
|
vuexState.config._syncMigration = [...migratedEntries]
|
||||||
|
|
@ -657,7 +657,12 @@ 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(recentData, staleData)
|
dirty = !isEqual(
|
||||||
|
// 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`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue