chore: use editable-edited event to sync changes (#2478)
Some checks are pending
Test & Docs / tests (postgresql, 3.10) (push) Waiting to run
Test & Docs / tests (postgresql, 3.12) (push) Waiting to run
Test & Docs / lint (push) Waiting to run
Test & Docs / docs (push) Waiting to run

This is more unified between markers and paths, and it allows paths to
be synced as soon as they have been drawn (instead of when closing the
edit panel, which created a race condition when changing its properties
that were then synced to other while the feature itself was not).
This commit is contained in:
Yohan Boniface 2025-02-07 09:12:45 +01:00 committed by GitHub
commit c5ee9fc283
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 5 deletions

View file

@ -47,6 +47,7 @@ const FeatureMixin = {
addInteractions: function () {
this.on('contextmenu editable:vertex:contextmenu', this.onContextMenu)
this.on('click', this.onClick)
this.on('editable:edited', this.onCommit)
},
onClick: function (event) {
@ -120,7 +121,6 @@ const PointMixin = {
this.feature.edit(event)
this.feature.pullGeometry()
})
this.on('editable:drawing:commit', this.onCommit)
if (!this.feature.isReadOnly()) this.on('mouseover', this._enableDragging)
this.on('mouseout', this._onMouseOut)
},
@ -287,7 +287,6 @@ const PathMixin = {
addInteractions: function () {
FeatureMixin.addInteractions.call(this)
this.on('editable:disable', this.onCommit)
this.on('mouseover', this._onMouseOver)
this.on('drag editable:drag', this._onDrag)
this.on('popupopen', this.highlightPath)

View file

@ -122,11 +122,11 @@ def test_websocket_connection_can_sync_polygons(context, asgi_live_server, tilel
map.click(position={"x": 100, "y": 100})
map.click(position={"x": 100, "y": 100})
# It is created on peerA, but not yet synced
# It is created on peerA, and should be on peerB
expect(a_polygons).to_have_count(1)
expect(b_polygons).to_have_count(0)
expect(b_polygons).to_have_count(1)
# Escaping the edition syncs
# Escaping the edition should not duplicate
peerA.keyboard.press("Escape")
expect(a_polygons).to_have_count(1)
expect(b_polygons).to_have_count(1)