From 6c8046456ae0c94004644f522b6e96a1f5c2f720 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 25 Apr 2025 09:44:49 +0200 Subject: [PATCH] chore: remove unused isDirty flags --- umap/static/umap/js/modules/data/features.js | 18 ------------------ umap/static/umap/js/modules/rendering/ui.js | 1 - umap/static/umap/js/modules/umap.js | 9 ++------- umap/static/umap/js/umap.controls.js | 8 -------- 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/umap/static/umap/js/modules/data/features.js b/umap/static/umap/js/modules/data/features.js index be5de91b..0b13947c 100644 --- a/umap/static/umap/js/modules/data/features.js +++ b/umap/static/umap/js/modules/data/features.js @@ -22,7 +22,6 @@ class Feature { constructor(umap, datalayer, geojson = {}, id = null) { this._umap = umap this.sync = umap.syncEngine.proxy(this) - this._isDirty = false this._ui = null // DataLayer the feature belongs to @@ -54,17 +53,6 @@ class Feature { } } - set isDirty(status) { - this._isDirty = status - if (this.datalayer) { - this.datalayer.isDirty = status - } - } - - get isDirty() { - return this._isDirty - } - get ui() { if (!this._ui) this.makeUI() return this._ui @@ -367,7 +355,6 @@ class Feature { } del(sync) { - this.isDirty = true this._umap._leafletMap.closePopup() if (this.datalayer) { this.datalayer.removeFeature(this, sync) @@ -412,13 +399,11 @@ class Feature { changeDataLayer(datalayer) { if (this.datalayer) { - this.datalayer.isDirty = true this.datalayer.removeFeature(this) } datalayer.addFeature(this) this.sync.upsert(this.toGeoJSON()) - datalayer.isDirty = true this.redraw() } @@ -485,7 +470,6 @@ class Feature { deleteProperty(property) { delete this.properties[property] - this.isDirty = true } renameProperty(from, to) { @@ -578,7 +562,6 @@ class Feature { delete geojson.id delete geojson.properties.id const feature = this.datalayer.makeFeature(geojson) - feature.isDirty = true feature.edit() return feature } @@ -1053,7 +1036,6 @@ export class LineString extends Path { this.pullGeometry() if (!this.ui.editEnabled()) this.edit() this.ui.editor.reset() - this.isDirty = true } isMulti() { diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 05b805a8..c5e5a6fc 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -109,7 +109,6 @@ const PointMixin = { addInteractions() { FeatureMixin.addInteractions.call(this) this.on('dragend', (event) => { - this.isDirty = true this.feature.edit(event) }) if (!this.feature.isReadOnly()) this.on('mouseover', this._enableDragging) diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index 238c8b99..f7435a99 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -640,7 +640,6 @@ export default class Umap { createDirtyDataLayer(options) { const datalayer = this.createDataLayer(options, true) - datalayer.isDirty = true return datalayer } @@ -1218,12 +1217,8 @@ export default class Umap { }) } } else { - if (!this.permissions.isDirty) { - // Do not override local changes to permissions, - // but update in case some other editors changed them in the meantime. - this.permissions.setProperties(data.permissions) - this.permissions.commit() - } + this.permissions.setProperties(data.permissions) + this.permissions.commit() this._leafletMap.once('saved', () => { Alert.success(data.info || translate('Map has been saved!')) }) diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 903502f8..9b1e0077 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -159,7 +159,6 @@ U.Search = L.PhotonSearch.extend({ event.stopPropagation() const datalayer = this.map._umap.defaultEditDataLayer() const marker = datalayer.makeFeature(feature) - marker.isDirty = true marker.edit() }) geom.addEventListener('mousedown', async (event) => { @@ -300,14 +299,8 @@ U.Editable = L.Editable.extend({ if (event.layer instanceof U.LeafletMarker) event.layer.feature.del() }) this.on('editable:drawing:commit', function (event) { - event.layer.feature.isDirty = true if (this._umap.editedFeature !== event.layer) event.layer.feature.edit(event) }) - this.on('editable:editing', (event) => { - const feature = event.layer.feature - feature.isDirty = true - // feature.pullGeometry(false) - }) this.on('editable:vertex:ctrlclick', (event) => { const index = event.vertex.getIndex() if ( @@ -361,7 +354,6 @@ U.Editable = L.Editable.extend({ // Overrided from Leaflet.Editable const datalayer = this._umap.defaultEditDataLayer() datalayer.addFeature(layer.feature) - layer.isDirty = true return layer },