itch app tab fetching strategy:
- grab what we can from local db (fast, doesn't usually fail)
- emit that so it can be rendered already
- fire API requests
- there may be several (multiple pages of games, for example)
- emit at each step so they can be rendered as soon as we got it
- any API request might fail
- because we're offline
- because of server/proxy issues
- because credentials are invalid (expired, revoked)
- there may be several (multiple pages of games, for example)
- any time we get new data, we should emit it
- if it's the same data, it shouldn't trigger a re-render
- pretty much no choice but to do a deep comparison here :/
- p.s timestamps are for humans, not skipping deep comparisons
- remote data & local data should be reconciled
- example: if local has all 4 pages of a collection but remote only has 1 so far, games shouldn't temporarily disappear from view. we can only be sure a game disappeared after remote is done fetching all its pages.
- if it's the same data, it shouldn't trigger a re-render
- fetching shouldn't hang forever
- if we should retry network requests, do we just cancel the fetch and schedule it again later, or do we handle retry inside the fetch?
- we should be able to cancel fetching
- don't do unnecessary API requests
- "when to fetch" is an open question
- when opening a new tab
- when switching to a tab
- on app focus
- when we come back online
- when tab is manually refreshed
- every once in a while (30 minutes right now)
- other corner cases: game tab after a game is purchased, for example
- fetching should be debounced/deduplicated
- several refresh conditions may happen at once, but we don't want 3x or 4x the API requests going out