geodesymiami / insarmaps

3 stars 0 forks source link

Can the browser history show details? #70

Closed falkamelung closed 2 years ago

falkamelung commented 2 years ago

Currently the browser history s not very useful (see below). Can we show more, e.g. when a new data set has been selected? We probably want to do it in a smart way and omit history entries for unimportant changes if that is possible.

image
stackTom commented 2 years ago

Done: https://github.com/geodesymiami/insarmaps/commit/2c99b4faadeb2a43515f526509167ac9d4b8cb8e

falkamelung commented 2 years ago

This is much more useful, but it shows a new history entry for everything, even if you only move slightly the area covered

image

It would be preferred to only create a history entry for major actions, such as (1) displaying a new dataset, (2) selecting a different time period. We could also count "displaying a point" as major action but for now just (1) and possible (2) is OK (2 is lower priority)

stackTom commented 2 years ago

This is not possible. Unless we stop updating certain things like zoom, start coordinates, etc. For the url system to work, we use a function called replaceState. The browser creates a new history entry when these are used, there is no way around it.

See here: https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API#the_replacestate_method

stackTom commented 2 years ago

I use replaceState rather than pushState so we don't create a new history entry. But notice what it says in the documentation about replaceState "Note that this doesn't prevent the creation of a new entry in the global browser history."

falkamelung commented 2 years ago

I see. It is not a big deal. Then lets keep it as it now is.