Greenstand / treetracker-web-map-client

The front end of the treetracker web map app.
http://map.treetracker.org
GNU Affero General Public License v3.0
64 stars 180 forks source link

Change to use cookie or localStorage to save the status of fullscreen #591

Closed dadiorchen closed 2 years ago

dadiorchen commented 2 years ago

Currently, we are using a query parameter embed: http://localhost:3000/planters/940/trees/186734?embed=true to indicate this is a fullscreen map, this approach has some downsides:

  1. problem prone: easy to lose the query jumping through pages.
  2. Ugly URL

We should find another solution for this, either cookies or localStorage,


Some hints:

svihang8 commented 2 years ago

Hey @dadiorchen. I've had a PR for one of your previous issues. I recently noticed this. If it is still available I would love to work on this issue. I believe we can make use of cookies to solve the issue. We can have a middleware function that can check to see if the required cookie exists. Thank you!

dadiorchen commented 2 years ago

@svihang8 sorry for the delay, thanks for what you've done for us, yes, please go forward and take this one. Because now we have adapted localStorage somewhere in this project, so I tend to use the same tech to handle this issue, is it okay? Please check this page: https://github.com/Greenstand/treetracker-web-map-client/search?q=storage

RubenSmn commented 2 years ago

@dadiorchen with 'fullscreen' do you mean whether or not the embed value in the url is true?

dadiorchen commented 2 years ago

@RubenSmn correct!

dadiorchen commented 2 years ago

@RubenSmn this one is problematic, in some case we must use the URL to control the embed behavior.

dadiorchen commented 2 years ago

BUT, maybe we can do in this way?

  1. Open: http://localhost:3000/planters/940/trees/186734?embed=true
  2. Display map in embedded mode
  3. Save the mode status into cookie/localstorage
  4. Jump to another page without ?embed=true
  5. Read the cookie/localstorage
  6. Display map in embedded mode
dadiorchen commented 2 years ago

Another solution: https://github.com/Greenstand/treetracker-web-map-client/issues/707

RubenSmn commented 2 years ago

BUT, maybe we can do in this way?

1. Open: http://localhost:3000/planters/940/trees/186734?embed=true

2. Display map in embedded mode

3. Save the mode status into cookie/localstorage

4. Jump to another page without `?embed=true`

5. Read the cookie/localstorage

6. Display map in embedded mode

@dadiorchen I think this is a good way to solve this issue

github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 2.0.0-beta.28 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: