diff --git a/umap/static/umap/js/modules/sync/engine.js b/umap/static/umap/js/modules/sync/engine.js index 8c1c2501..2e098efc 100644 --- a/umap/static/umap/js/modules/sync/engine.js +++ b/umap/static/umap/js/modules/sync/engine.js @@ -399,6 +399,7 @@ export class SyncEngine { onSavedMessage({ sender, lastKnownHLC }) { debug(`received saved message from peer ${sender}`, lastKnownHLC) this._operations.saved(lastKnownHLC) + this._undoManager.toggleState() } /** @@ -471,7 +472,7 @@ export class Operations { } saved(hlc) { - for (const operation of this.getOperationsSince(hlc)) { + for (const operation of this.getOperationsBefore(hlc)) { operation.dirty = false } } @@ -543,6 +544,11 @@ export class Operations { return this._operations.filter((op) => op.hlc > hlc) } + getOperationsBefore(hlc) { + if (!hlc) return this._operations + return this._operations.filter((op) => op.hlc <= hlc) + } + /** * Returns the last known HLC value. */