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 }) {
|
||||
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() {
|
||||
|
|
|
@ -169,7 +169,7 @@ export class SyncEngine {
|
|||
this._send(operation)
|
||||
}
|
||||
|
||||
update(subject, metadata, key, value, oldValue) {
|
||||
update(subject, metadata, key, value, oldValue, { undo } = { undo: true }) {
|
||||
const operation = {
|
||||
verb: 'update',
|
||||
subject,
|
||||
|
@ -186,7 +186,7 @@ export class SyncEngine {
|
|||
this._batch.push(stage)
|
||||
return
|
||||
}
|
||||
this._undoManager.add(stage)
|
||||
if (undo) this._undoManager.add(stage)
|
||||
this._send(operation)
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ export class SyncEngine {
|
|||
async save() {
|
||||
const needSave = new Map()
|
||||
if (!this._umap.id) {
|
||||
// There is no operation for fist map save
|
||||
// There is no operation for first map save
|
||||
needSave.set(this._umap, [])
|
||||
}
|
||||
for (const operation of this._operations.sorted()) {
|
||||
|
|
|
@ -35,13 +35,10 @@ export class UndoManager {
|
|||
}
|
||||
|
||||
add(stage) {
|
||||
// FIXME make it more generic
|
||||
if (!stage.operation || stage.operation.key !== '_referenceVersion') {
|
||||
stage.operation.dirty = true
|
||||
this._redoStack = []
|
||||
this._undoStack.push(stage)
|
||||
this.toggleState()
|
||||
}
|
||||
stage.operation.dirty = true
|
||||
this._redoStack = []
|
||||
this._undoStack.push(stage)
|
||||
this.toggleState()
|
||||
}
|
||||
|
||||
copyOperation(stage, redo) {
|
||||
|
|
Loading…
Reference in a new issue