feat(sync): Only sync when on edit mode

The is done to save server resources, for accessed maps which
aren't currently being edited.
This commit is contained in:
Alexis Métaireau 2024-05-07 12:29:16 +02:00
parent 66eb90ffd1
commit c6ee25b906

View file

@ -249,8 +249,6 @@ U.Map = L.Map.extend({
this.initContextMenu() this.initContextMenu()
this.on('click contextmenu.show', this.closeInplaceToolbar) this.on('click contextmenu.show', this.closeInplaceToolbar)
this.sync = new U.SyncEngine(this) this.sync = new U.SyncEngine(this)
this.initSyncEngine()
}, },
initSyncEngine: async function () { initSyncEngine: async function () {
@ -1602,6 +1600,7 @@ U.Map = L.Map.extend({
this.editEnabled = true this.editEnabled = true
this.drop.enable() this.drop.enable()
this.fire('edit:enabled') this.fire('edit:enabled')
this.initSyncEngine()
}, },
disableEdit: function () { disableEdit: function () {
@ -1613,6 +1612,7 @@ U.Map = L.Map.extend({
this.fire('edit:disabled') this.fire('edit:disabled')
this.editPanel.close() this.editPanel.close()
this.fullPanel.close() this.fullPanel.close()
this.sync.stop()
}, },
hasEditMode: function () { hasEditMode: function () {