mirror of
https://github.com/Start9Labs/patch-db.git
synced 2026-04-01 20:54:14 +00:00
local sequence bug
This commit is contained in:
@@ -38,10 +38,9 @@ export class Store<T extends { [key: string]: any }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update (update: Update<T>): void {
|
update (update: Update<T>): void {
|
||||||
// if old or known, return
|
|
||||||
if (update.id <= this.cache.sequence || this.stash.get(update.id)) return
|
|
||||||
|
|
||||||
if (this.isRevision(update)) {
|
if (this.isRevision(update)) {
|
||||||
|
// if old or known, return
|
||||||
|
if (update.id <= this.cache.sequence || this.stash.get(update.id)) return
|
||||||
this.handleRevision(update)
|
this.handleRevision(update)
|
||||||
} else {
|
} else {
|
||||||
this.handleDump(update)
|
this.handleDump(update)
|
||||||
@@ -52,6 +51,7 @@ export class Store<T extends { [key: string]: any }> {
|
|||||||
Object.values(this.watchedNodes).forEach(node => node.complete())
|
Object.values(this.watchedNodes).forEach(node => node.complete())
|
||||||
this.watchedNodes = { }
|
this.watchedNodes = { }
|
||||||
this.stash.clear()
|
this.stash.clear()
|
||||||
|
this.sequence$.next(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRevision (revision: Revision): void {
|
private handleRevision (revision: Revision): void {
|
||||||
@@ -76,7 +76,6 @@ export class Store<T extends { [key: string]: any }> {
|
|||||||
Object.entries(dump.value).forEach(([key, val]) => {
|
Object.entries(dump.value).forEach(([key, val]) => {
|
||||||
(this.cache.data as any)[key] = val
|
(this.cache.data as any)[key] = val
|
||||||
})
|
})
|
||||||
|
|
||||||
this.stash.deleteRange(this.cache.sequence, dump.id, false)
|
this.stash.deleteRange(this.cache.sequence, dump.id, false)
|
||||||
this.updateWatchedNodes('')
|
this.updateWatchedNodes('')
|
||||||
this.updateSequence(dump.id)
|
this.updateSequence(dump.id)
|
||||||
@@ -101,7 +100,6 @@ export class Store<T extends { [key: string]: any }> {
|
|||||||
|
|
||||||
private applyRevisions (id: number): void {
|
private applyRevisions (id: number): void {
|
||||||
let revision = this.stash.get(id)?.revision
|
let revision = this.stash.get(id)?.revision
|
||||||
|
|
||||||
while (revision) {
|
while (revision) {
|
||||||
let undo: Operation[] = []
|
let undo: Operation[] = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user