Fix conflict on removed values in repository
This commit is contained in:
Generated
+1
-1
@@ -3635,7 +3635,7 @@
|
|||||||
},
|
},
|
||||||
"packages/app": {
|
"packages/app": {
|
||||||
"name": "@welshman/app",
|
"name": "@welshman/app",
|
||||||
"version": "0.0.16",
|
"version": "0.0.17",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@welshman/dvm": "~0.0.10",
|
"@welshman/dvm": "~0.0.10",
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ export const deriveEventsMapped = <T>(repository: Repository, {
|
|||||||
for (const update of updates) {
|
for (const update of updates) {
|
||||||
for (const event of update.added.values()) {
|
for (const event of update.added.values()) {
|
||||||
added.set(event.id, event)
|
added.set(event.id, event)
|
||||||
|
removed.delete(event.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const id of update.removed) {
|
for (const id of update.removed) {
|
||||||
|
|||||||
@@ -32,24 +32,7 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load = (events: E[], chunkSize = 1000) => {
|
load = (events: E[], chunkSize = 1000) => {
|
||||||
this.clear()
|
|
||||||
|
|
||||||
const added = []
|
const added = []
|
||||||
|
|
||||||
for (const eventsChunk of chunk(chunkSize, events)) {
|
|
||||||
for (const event of eventsChunk) {
|
|
||||||
if (this.publish(event, {shouldNotify: false})) {
|
|
||||||
added.push(event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const removed = new Set(this.deletes.keys())
|
|
||||||
|
|
||||||
this.emit('update', {added, removed})
|
|
||||||
}
|
|
||||||
|
|
||||||
clear = () => {
|
|
||||||
const removed = new Set(this.eventsById.keys())
|
const removed = new Set(this.eventsById.keys())
|
||||||
|
|
||||||
this.eventsById.clear()
|
this.eventsById.clear()
|
||||||
@@ -60,7 +43,16 @@ export class Repository<E extends HashedEvent = TrustedEvent> extends Emitter {
|
|||||||
this.eventsByAuthor.clear()
|
this.eventsByAuthor.clear()
|
||||||
this.deletes.clear()
|
this.deletes.clear()
|
||||||
|
|
||||||
this.emit('update', {added: [], removed})
|
for (const eventsChunk of chunk(chunkSize, events)) {
|
||||||
|
for (const event of eventsChunk) {
|
||||||
|
if (this.publish(event, {shouldNotify: false})) {
|
||||||
|
added.push(event)
|
||||||
|
removed.delete(event.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emit('update', {added, removed})
|
||||||
}
|
}
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|||||||
Reference in New Issue
Block a user