fix tests

This commit is contained in:
Henry Jameson 2026-01-23 17:24:02 +02:00
commit 3cdcb87831
11 changed files with 165 additions and 82 deletions

View file

@ -237,6 +237,7 @@ const _mergeJournal = (...journals) => {
return false
}
if (a.operation === 'addToCollection') {
// TODO check how objectCollections behaves here
return a.args[0] === b.args[0]
}
return false
@ -500,6 +501,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
collection.add(_key)
set(this.prefsStorage, path + '.index', [...collection])
set(this.prefsStorage, path + '.data.' + _key, value)
console.log(get(path, this.prefsStorage, path))
}
this.prefsStorage._journal = [
...this.prefsStorage._journal,
@ -518,19 +520,28 @@ export const useSyncConfigStore = defineStore('sync_config', {
`tried to edit internal (starts with _) field '${path}', ignoring.`,
)
}
const collection = new Set(get(this.prefsStorage, path))
collection.delete(value)
set(this.prefsStorage, path, [...collection])
this.prefsStorage._journal = [
...this.prefsStorage._journal,
{
operation: 'removeFromCollection',
path,
args: [value],
timestamp: Date.now(),
},
]
this.dirty = true
const { _key } = value
if (path.startsWith('collection')) {
const collection = new Set(get(this.prefsStorage, path))
collection.delete(value)
set(this.prefsStorage, path, [...collection])
this.prefsStorage._journal = [
...this.prefsStorage._journal,
{
operation: 'removeFromCollection',
path,
args: [value],
timestamp: Date.now(),
},
]
this.dirty = true
} else if (path.startsWith('objectCollection')) {
const collection = new Set(get(this.prefsStorage, path + '.index'))
collection.delete(_key)
const data = get(this.prefsStorage, path + '.data')
delete data[_key]
}
},
reorderCollectionPreference({ path, value, movement }) {
if (path.startsWith('_')) {