mikelambert / dancedeets-monorepo

DanceDeets Codebase: The python server (with React.JS rendering), as well as the React Native mobile app (and their shared code)
http://www.dancedeets.com
21 stars 2 forks source link

[Mobile] Cached GPS and/or Event Data #1

Open mikelambert opened 7 years ago

mikelambert commented 7 years ago

When we open the app, it does a GPS lookup for lat/long (takes a second or so), then uses that to do a reverse geocode to get an address/city (takes another second), then uses that to do a DanceDeets API search for data (which is another few seconds).

A few things can be improved here on loading the "list of events", making everything much faster to load on app startup.

-- We could look at the current scrolled item, and re-scroll to that item in the new dataset (if it still exists). -- We could do some "are we online?" check at the very beginning. If we are not online (or the search results fail), we show the cached data. If we are online, we show-nothing, and then show the downloaded data as soon as it arrives. -- Open to other ideas here if you got them?

The code is in mobile/js/events/list.js code and starts in the initialize() function flow.

mikelambert commented 7 years ago

You can probably use AsyncStorage to store stuff locally.

The app uses redux (another technology you'll probably need to learn for the react-native world), so in theory we could probably just use redux-persist as well, and persist our entire app state to disk. It's appealing, and might even be the best option to keep the code size and complexity down.

I mostly worry that if the internal app state gets corrupted for some reason...an app restart won't actually clear the app state, and so it may be impossible to recover from bad app bugs. :( I believe it's possible to only rehydrate certain reducers (according to this), so it might be possible to restrict our state-rehydration to just the search and searchHeader keys (which is basically the search state) and simplify things without too much danger.

trisrael commented 7 years ago

I like the idea of using redux-persist to get the fastest implementation + simplicity. I'll try this route first looking for major gotchas that come up, for instance the size limit of storage.

As the online/cached behavior.. Normally, there is some global navigation notifier that could work for either offline or data being fetched, so the user knows that something is happening. Normally I am used to just a persistent flash message or some static area with an icon denoting what is occurring.

I will look around for some designs, but mostly I'll have to play a bit first to have a better idea about suggestions.