From 4c717106414dd8df0aa8873c109f40f64e2b9ba2 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Wed, 23 Apr 2025 08:57:26 +0200 Subject: [PATCH] fix: do not display "saved" message if some request failed --- umap/static/umap/js/modules/sync/engine.js | 3 ++- umap/static/umap/js/modules/umap.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/modules/sync/engine.js b/umap/static/umap/js/modules/sync/engine.js index b6f0d151..f117b259 100644 --- a/umap/static/umap/js/modules/sync/engine.js +++ b/umap/static/umap/js/modules/sync/engine.js @@ -225,13 +225,14 @@ export class SyncEngine { } for (const [obj, operations] of needSave.entries()) { const ok = await obj.save() - if (!ok) break + if (!ok) return false for (const operation of operations) { operation.dirty = false } } this.saved() this._undoManager.toggleState() + return true } saved() { diff --git a/umap/static/umap/js/modules/umap.js b/umap/static/umap/js/modules/umap.js index 980ac1b8..7059c626 100644 --- a/umap/static/umap/js/modules/umap.js +++ b/umap/static/umap/js/modules/umap.js @@ -691,7 +691,8 @@ export default class Umap { if (!this.isDirty) return if (this._defaultExtent) this._setCenterAndZoom() this.backup() - await this.sync.save() + const status = await this.sync.save() + if (!status) return // Do a blind render for now, as we are not sure what could // have changed, we'll be more subtil when we'll remove the // save action