Currently location is being tracked in the LocationView component. This means that the location is only being tracked when the location view is mounted, so it is not being tracked when the user is choosing a preset, editting an observation field, or taking a photo. Also since the LocationView can be unmounted (during all those activities just listed) the most accurate location can be overwritten by the newer location,
To solve this we can tie the subscription of the location to the state of of an observation. That is, when draft observation !== null we can start tracking the observation. This will require us to start the subscription outside of react state.
To Do:
[ ] create the zustand store of persisted observation in global scope.
[ ] create the selector within a context scope, pass both store and selector in context.
[ ] store subscription to location within context scope
[ ] subscribe when creating draft observation
[ ] unsubscribe when saving draft observation
[ ] save entire location object from expo (not just lat lon)
[ ] derive position.mocked from expo location
[ ] check whether observation is new (aka, does not have a docId), and only start subscription if it is new (to prevent overwritting the location when editing a previously saved observation)
Currently location is being tracked in the
LocationView
component. This means that the location is only being tracked when the location view is mounted, so it is not being tracked when the user is choosing apreset
, editting anobservation field
, or taking aphoto
. Also since theLocationView
can be unmounted (during all those activities just listed) the most accurate location can be overwritten by the newer location,To solve this we can tie the subscription of the location to the state of of an observation. That is, when
draft observation !== null
we can start tracking the observation. This will require us to start the subscription outside of react state.To Do:
position.mocked
from expo location