wip: uncreated map should always appear as dirty

This commit is contained in:
Yohan Boniface 2025-03-23 12:28:38 +01:00
parent d0fb85d552
commit a2e864ad73
3 changed files with 5 additions and 2 deletions

View file

@ -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() {

View file

@ -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
}

View file

@ -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()
}
}