untitaker / taskrs

A tasks app
https://community.remotestorage.io/t/synchronization-with-carddav-caldav/307
MIT License
6 stars 1 forks source link

Offline support #20

Open nlehuby opened 8 years ago

nlehuby commented 8 years ago

When I try to use taskrs with no connection, I only get a "loading" message and the offline remoteStorage widget, but I cannot access my tasks anymore.

screenshot

untitaker commented 8 years ago

Could you try https://developer.mozilla.org/en/docs/Tools/Remote_Debugging/Debugging_Firefox_for_Android_with_WebIDE to debug the error? I'm semi-sure there is one.

untitaker commented 8 years ago

BTW this is just what I've been using for debugging Firefox for Android, YMMV.

untitaker commented 8 years ago

Nevermind, I can reproduce it as well. Weird, will take a look. Thanks for reporting!

nlehuby commented 8 years ago

It does work when you go offline after initially loading the app ; this bug only occurs when you first load the page offline. https://github.com/remotestorage/remotestorage.js/issues/869

raucao commented 8 years ago

I remember us chatting about it on IRC, so just to add it as persistent note here: rs.js currently thinks it's online when loaded (hence linked issue in previous comment), and only sets itself to offline when the first network request fails. If an app uses something like BaseClient#getAll with a (default) maxAge (for cache updates) as first, blocking method for showing data from remoteStorage, then that will fail, if the rejected promise isn't caught and the request is retried.

So this is both a problem of developer UX with this library as well as of this app (until the library handles this in a better way that lets the developer worry about it less).

untitaker commented 8 years ago

@skddc So what exactly should be changed? I do use default maxAge.

raucao commented 8 years ago

You can try to catch the rejected getAll Promise and then set maxAge to false in a second getAll request you'd do from there.

Alternatively, you could set remoteStorage.remote.online to false right away so it would get things from cache immediately. But then you'd have to listen for incoming change events and add items from those, because otherwise you'd not see new items until you getAll again (or any items if the cache is empty for that matter).

untitaker commented 7 years ago

@skddc is this changed in 0.14.0? I'm reviving this app again.

raucao commented 7 years ago

No, this is still the same behaviour afaik. So my first comment should still apply.

I think with apps for which you usually assume connectivity, it would still be best to catch the rejected promise and retry with maxAge set to false. This way you get the best performance and behaviour for all situations, except when offline during app startup, where it would take a little bit longer for first load.