stac-browser icon indicating copy to clipboard operation
stac-browser copied to clipboard

Pagination state

Open rowanwins opened this issue 3 years ago • 7 comments

This PR adds support for sharing links with the pagination state, for example if you are on page 2 of a set of collection items and share the link the user will open to page 2 of the results.

I wouldn't say I'm overly happy with where the logic is placed in the store because in many regards this code should only run once when the app loads but I found it difficult to move the code anywhere else.

Still need to test what happens on static catalogs.

rowanwins avatar Jul 25 '22 01:07 rowanwins

Note for self - there are some APIs that don't use the token param, for example this one uses startRecord, so probably need to work out how to make the handling more generic.

rowanwins avatar Jul 25 '22 02:07 rowanwins

Yeah, this will only work for a small subset of APIs. Please check the API spec again regarding pagination because this doesn't really follow the spec. You'll may need to serialize the whole link in some cases. We should probably figure out some smart logic that only serializes what is really different in the link...

m-mohr avatar Jul 25 '22 09:07 m-mohr

@m-mohr just pushed up a commit that basically serialises the whole link object, seems to work a bit more safely across different catalogs

rowanwins avatar Jul 26 '22 05:07 rowanwins

Thanks. This is not how I expect this to work, the approach taken is too simple because now it gives an overly long URL in all cases. It should really detect whether a full serialization is required or whether only a query parameter has been added to the "base URL" and then only persist that specific parameter into the URL. Also, you only need to persist the parts related to the request from the Link Object.

m-mohr avatar Aug 01 '22 18:08 m-mohr

I've made a minor tweak that slims down the url to only containing the querystring for GET request pagination. This isn't as s slim as possible but it's an improvement.

rowanwins avatar Aug 02 '22 00:08 rowanwins

Part of the challenge around this is where we manage the state for limit and also the filter params like bbox and datetime, these things typically get captured in a GET href but are also part of the app state 🤯

rowanwins avatar Aug 02 '22 00:08 rowanwins

Is that really an issue? The app state for the form seems unrelated to the actual search results and the pagination and as such should be stored separately. But maybe I'm not fully understanding the challenges yet.

m-mohr avatar Aug 02 '22 12:08 m-mohr