Skip to content

PB-89: Fix preview of geojson layers#749

Merged
ltshb merged 4 commits intodevelopfrom
bug-PB-89-preview-geojson
Apr 2, 2024
Merged

PB-89: Fix preview of geojson layers#749
ltshb merged 4 commits intodevelopfrom
bug-PB-89-preview-geojson

Conversation

@ltshb
Copy link
Contributor

@ltshb ltshb commented Mar 28, 2024

For testing enter ch.meteoschweiz.messwerte-niederschlag in the search
bar and hover the results.

Test link

@github-actions github-actions bot added the bug label Mar 28, 2024
@ltshb ltshb force-pushed the bug-PB-89-preview-geojson branch 2 times, most recently from bee8c97 to 182c0da Compare March 28, 2024 08:07
@cypress
Copy link

cypress bot commented Mar 28, 2024

Passing run #1415 ↗︎

0 166 22 0 Flakiness 0

Details:

PB-89: Solved preview debouncing issues
Project: web-mapviewer Commit: 3d096746db
Status: Passed Duration: 05:16 💡
Started: Apr 2, 2024 6:49 AM Ended: Apr 2, 2024 6:55 AM

Review all test suite changes for PR #749 ↗︎

@ltshb ltshb requested review from LukasJoss and pakb March 28, 2024 08:15
Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small issue I see with this approach, the await means that the GeoJSON will be added as preview layer wherever is the mouse when this finishes.
There's a feature of axios called cancel token that should be leverage here, so that if the mouse goes out of the GeoJSON layer we cancel the pending request.

If you want to see this issue "live", search for "Temperature", quickly go trough "Temperature, 2m min" and end your move on any other layer (that is no GeoJSON) in the searchbar, after 1sec or more, the preview layer will be forced to the GeoJSON instead of the one currently under the mouse

@ltshb
Copy link
Contributor Author

ltshb commented Mar 28, 2024

Small issue I see with this approach, the await means that the GeoJSON will be added as preview layer wherever is the mouse when this finishes. There's a feature of axios called cancel token that should be leverage here, so that if the mouse goes out of the GeoJSON layer we cancel the pending request.

If you want to see this issue "live", search for "Temperature", quickly go trough "Temperature, 2m min" and end your move on any other layer (that is no GeoJSON) in the searchbar, after 1sec or more, the preview layer will be forced to the GeoJSON instead of the one currently under the mouse

Yea I just saw this issue, thanks for the axios tip I'll have a look

@ltshb ltshb force-pushed the bug-PB-89-preview-geojson branch from 182c0da to 3190e1c Compare March 28, 2024 10:01
ltshb added 3 commits March 28, 2024 12:54
Sometimes during the releases build the test "reads and adds an external WMTS correctly"
reached the timeout of waitMapIsReady. It seems to occur only during release
build strangely.
Jumping between category worked only when the previous category had inputs.
@ltshb ltshb force-pushed the bug-PB-89-preview-geojson branch from 3190e1c to 3e7e737 Compare March 28, 2024 15:06
@ltshb ltshb requested a review from pakb March 28, 2024 15:11
@ltshb ltshb force-pushed the bug-PB-89-preview-geojson branch from 3e7e737 to 89869a1 Compare March 28, 2024 15:15
The preview of a search entry can be quite time processing and needed to have some
debouncing to avoid too many store dispatch. Also if the preview was a geojson
layer that needs to be loaded we needed a way to cancel the load if it was
still ongoing when clearing the preview.

To solve those issue the preview layer is delegated to the search list component
which is responsible to send the preview dispatch. This also allow to avoid
sending in a row a clear and set dispatch when changing focus from one entry
to the other.

Now we also have the preview when navigating with the keypboard.

The geojson preview loading is also aborted when preview is cleared.
@ltshb ltshb force-pushed the bug-PB-89-preview-geojson branch from 89869a1 to 3d09674 Compare April 2, 2024 06:46
Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small question, but overall looking good as it is

Comment on lines +103 to +104
async function loadAndUpdatePreviewLayer(store, layer) {
cancelLoadPreviewLayer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we shouldn't check which layer we are loading. Because if we are hover a GeoJSON and then clicking it very quickly, this means this will cancel the initial load of data/style for the layer, and we will fire it once more to show it definitively on the map...
I don't know if this would bring too much complexity here, your thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pakb good point, however this would add much complexity. Currently the preview layer object and the active layer object are two different object, therefore when the layer is added it reload the geojson data and style for the new object. We could in theory reuse the preview object instead of creating a new object, but I think this would complexify the code and could bring more trouble. If the geojson style and data have proper cache-control header (I check a few meteoswiss layers) then we don't have any performance issue as the second load is done by the browser cache.

@ltshb ltshb merged commit 7958d63 into develop Apr 2, 2024
@ltshb ltshb deleted the bug-PB-89-preview-geojson branch April 2, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants