Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember location #727

Closed
xoorath opened this issue Sep 13, 2020 · 6 comments · Fixed by #752
Closed

Remember location #727

xoorath opened this issue Sep 13, 2020 · 6 comments · Fixed by #752
Assignees
Labels
F-idea A good idea! good first issue Good for newcomers Hacktoberfest https://hacktoberfest.digitalocean.com/

Comments

@xoorath
Copy link

xoorath commented Sep 13, 2020

If you do not give location permissions to the app you have to type in your location every time you launch.

I think it would be preferable to remember the last location used if location permissions are disabled.

@amaury1093 amaury1093 added the good first issue Good for newcomers label Sep 14, 2020
@amaury1093
Copy link
Member

That's a very good idea! Would you like to create a PR for this?

@amaury1093 amaury1093 added the F-idea A good idea! label Sep 20, 2020
@amaury1093 amaury1093 added the Hacktoberfest https://hacktoberfest.digitalocean.com/ label Oct 1, 2020
@Hackodia3t
Copy link

save the location given by network if location permission is not granted

@HaramanJohal
Copy link
Contributor

I'm happy to have a go at this if I could get some pointers. Here's my rough plan of action:

I can use AsyncStorage to store the location, I can save this location each time the GPS is actually queried in location.tsx. Then instead of defaulting to the hardcoded latitude and longitude it should default to the saved location if available. (I guess the app will only use the hardcoded default until the first time it can get a gps signal)

@HaramanJohal
Copy link
Contributor

Is it better to set the default state value to the last saved location or should we instead attempt GPS first and only fall back if there's an error?
My feeling is that the first is better as it should load quicker...

@amaury1093
Copy link
Member

should we instead attempt GPS first and only fall back if there's an error

We should definitely do that. If the user physically moves (e.g. go to another city), we want to show the pollution of the new city, and not the previously stored one.

AsyncStorage is definitely the way to go 👍

So the flow is:

  • on app first ever launch, we fetch GPS
    • if it errors, we show the error screen, and user searches manually for a location
    • if not, then we show the current location's cigarettes
    • in every case, once a location has been set (the currentLocation field in location.tsx), we save it to AsyncStorage
  • on app subsequent launches, we fetch GPS
    • if it errors, we populate currentLocation from AsyncStorage
    • if not, then same as before

Does this make sense @HaramanJohal ? What do you think about it?

I assigned you, let me know if you need help! And thanks for volunteering!

@HaramanJohal
Copy link
Contributor

We should definitely do that. If the user physically moves (e.g. go to another city), we want to show the pollution of the new city, and not the previously stored one

This makes sense, and the flow seems logical, I'll give it a go and let you know if I get stuck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-idea A good idea! good first issue Good for newcomers Hacktoberfest https://hacktoberfest.digitalocean.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants