mlandauer / thats-camping-elm

Find campsites near you
https://thatscamping.org
GNU General Public License v3.0
5 stars 1 forks source link

Optimise syncing with remote repo to reduce network traffic #108

Open mlandauer opened 7 years ago

mlandauer commented 7 years ago

Currently we're doing continuous two-way synching which is great from a simplicity point-of-view but pretty bad in terms of battery and network usage.

So, normally just do a synch from remote to local and only do this on startup and every 5 minutes or so.

If the user makes local changes to the database immediately save something in localstorage to say there are outstanding local changes and try to sync local -> remote. If that synch works remove the flag in localstorage. On the normal synch that occurs every 5 minutes or so check if the flag is set in localstorage. If there are outstanding changes then try a two-way synch.