diff --git a/umap/static/umap/js/modules/sync/engine.js b/umap/static/umap/js/modules/sync/engine.js index 12487ef6..d1875bcd 100644 --- a/umap/static/umap/js/modules/sync/engine.js +++ b/umap/static/umap/js/modules/sync/engine.js @@ -73,7 +73,7 @@ export class SyncEngine { this.websocketConnected = false this.closeRequested = false this.peerId = Utils.generateId() - this._undoManager = new UndoManager(this.updaters, this) + this._undoManager = new UndoManager(umap, this.updaters, this) } get isOpen() { diff --git a/umap/static/umap/js/modules/sync/undo.js b/umap/static/umap/js/modules/sync/undo.js index 954b6955..e96bcf9d 100644 --- a/umap/static/umap/js/modules/sync/undo.js +++ b/umap/static/umap/js/modules/sync/undo.js @@ -2,7 +2,8 @@ import * as Utils from '../utils.js' import { DataLayerUpdater, FeatureUpdater, MapUpdater } from './updaters.js' export class UndoManager { - constructor(updaters, syncEngine) { + constructor(umap, updaters, syncEngine) { + this._umap = umap this._syncEngine = syncEngine this.updaters = updaters this._undoStack = [] @@ -25,6 +26,7 @@ export class UndoManager { } isDirty() { + if (!this._umap.id) return true for (const stage of this._undoStack) { if (stage.operation.dirty) return true } diff --git a/umap/static/umap/js/modules/ui/bar.js b/umap/static/umap/js/modules/ui/bar.js index d54ea866..78d5eae4 100644 --- a/umap/static/umap/js/modules/ui/bar.js +++ b/umap/static/umap/js/modules/ui/bar.js @@ -162,6 +162,7 @@ export class TopBar extends WithTemplate { this.elements.view.disabled = this._umap.sync._undoManager.isDirty() this.elements.saveLabel.hidden = this._umap.permissions.isDraft() this.elements.saveDraftLabel.hidden = !this._umap.permissions.isDraft() + this._umap.sync._undoManager.toggleState() } }