mirror of
https://github.com/umap-project/umap.git
synced 2025-05-05 22:11:50 +02:00
wip: allow to mark an operation as not undoable
Co-authored-by: David Larlet <david@larlet.fr>
This commit is contained in:
parent
88382ab00b
commit
9718f11faf
3 changed files with 12 additions and 11 deletions
|
@ -1098,7 +1098,11 @@ export class DataLayer extends ServerStored {
|
||||||
|
|
||||||
setReferenceVersion({ response, sync }) {
|
setReferenceVersion({ response, sync }) {
|
||||||
this._referenceVersion = response.headers.get('X-Datalayer-Version')
|
this._referenceVersion = response.headers.get('X-Datalayer-Version')
|
||||||
if (sync) this.sync.update('_referenceVersion', this._referenceVersion)
|
if (sync) {
|
||||||
|
this.sync.update('_referenceVersion', this._referenceVersion, null, {
|
||||||
|
undo: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save() {
|
||||||
|
|
|
@ -169,7 +169,7 @@ export class SyncEngine {
|
||||||
this._send(operation)
|
this._send(operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
update(subject, metadata, key, value, oldValue) {
|
update(subject, metadata, key, value, oldValue, { undo } = { undo: true }) {
|
||||||
const operation = {
|
const operation = {
|
||||||
verb: 'update',
|
verb: 'update',
|
||||||
subject,
|
subject,
|
||||||
|
@ -186,7 +186,7 @@ export class SyncEngine {
|
||||||
this._batch.push(stage)
|
this._batch.push(stage)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._undoManager.add(stage)
|
if (undo) this._undoManager.add(stage)
|
||||||
this._send(operation)
|
this._send(operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ export class SyncEngine {
|
||||||
async save() {
|
async save() {
|
||||||
const needSave = new Map()
|
const needSave = new Map()
|
||||||
if (!this._umap.id) {
|
if (!this._umap.id) {
|
||||||
// There is no operation for fist map save
|
// There is no operation for first map save
|
||||||
needSave.set(this._umap, [])
|
needSave.set(this._umap, [])
|
||||||
}
|
}
|
||||||
for (const operation of this._operations.sorted()) {
|
for (const operation of this._operations.sorted()) {
|
||||||
|
|
|
@ -35,13 +35,10 @@ export class UndoManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
add(stage) {
|
add(stage) {
|
||||||
// FIXME make it more generic
|
stage.operation.dirty = true
|
||||||
if (!stage.operation || stage.operation.key !== '_referenceVersion') {
|
this._redoStack = []
|
||||||
stage.operation.dirty = true
|
this._undoStack.push(stage)
|
||||||
this._redoStack = []
|
this.toggleState()
|
||||||
this._undoStack.push(stage)
|
|
||||||
this.toggleState()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
copyOperation(stage, redo) {
|
copyOperation(stage, redo) {
|
||||||
|
|
Loading…
Reference in a new issue