Glider icon indicating copy to clipboard operation
Glider copied to clipboard

Offline functionality

Open Victor239 opened this issue 4 years ago • 4 comments

It would be great if the headlines and comments were cached so that if you open the app whilst offline you can still read them. If online however it would automatically refresh as per usual.

Victor239 avatar Apr 29 '21 06:04 Victor239

Yup, would be nice. Can you tell me a bit more about your use case? Do you think the app should just cache the responses of all the pages you've visited, or should it also have a way to greedily retrieve comments of stories you have not opened (yet) to allow for a more fully-featured offline experience?

Mosc avatar May 01 '21 17:05 Mosc

My usecase is reading HN whilst I have no internet access due to being on a train underground, which is up to an hour on certain days.

Just caching all headlines + the comments of visited pages would be sufficient for me really.

There's a similar option on a Reddit app I use to schedule retrieving all comments and posts of a subreddit, but I don't use it because I don't feel a need for it to download so many posts from so many subreddits at least once a day. With HN it's far less posts so maybe in this case I might enable it if it were an option, not sure though.

Victor239 avatar May 01 '21 19:05 Victor239

Chiming in to say that I'd love to see this getting implemented. My use-case would be similar to Victor239, but I'd prefer the ability to schedule download all posts and comments (maybe give a configuration option to select how many stories does the user want to save for each category). Since this is all text, caching would not put a whole lot of dent into the storage space also.

Thanks for building this app btw! I just came across it on Fdroid, played around with it a bit and instantly fell in love. Kudos! :100:

thelazyoxymoron avatar May 06 '21 07:05 thelazyoxymoron

Offline functionality has been implemented in db8f65d72a91658fe96fdeb126f0a0da68990669 and 1260819c99f9122dd3b58609acbd1e237ac75a00. The app will cache every successful HTTP GET request during normal use for a period of 7 days. When any HTTP error occurs (which happens not only when the user is offline, but also when, for instance, the Hacker News server is down) this cache will be used as a fallback. The relevant item will gain an icon to indicate it's pulled from the cache. In addition, if the app detects that the user is not connected to any network, a banner will be shown to indicate that information may not be up-to-date. I'll release a new app version that includes this change soon.

I'm still working on the best way of exposing the preloading part that @thelazyoxymoron requested. A relatively easy way would be to make it a manual action accessed from the menu:

Scheduling is an option, but introduces a number of additional complexities:

  • How frequently do we run the preloading task? And at what time? Is it okay to run on a metered connection?
  • Although the app is currently only released for Android, I'd like it to work as well as possible on every platform that Flutter supports. Scheduling would appear to be limited to Android and iOS through something like workmanager. The iOS part of that provides basically no customization. flt_worker is a promising alternative.
  • Apparently some device manufacturers require user permission before the app can autostart after reboots.

Mosc avatar May 19 '21 15:05 Mosc