Code Insights: Revisit UX for insight loading state for background data fetching
Created by: vovakulikov
blocked by Insights: Served cached insight data against insight dashboards
Context
We are going to adopt the Apollo cache system for loading backend insights on the dashboard page. In the nutshell, this system works in this way
On the first-page visit
- We open the dashboard page
- We start loading insights sequentially in parallel by 2 (like we do this now on the sourcegraph.com)
- While loading is happening we show loading state (insight card with no content but with loader instead)
- When the backend responds with data we hide the loading state and show either the data or some error state.
The most interesting thing here is that after the backend returned our data we put the in the cache. In the next time when we visit the dashboard page, we could use our cached insight data and show insight immediately without an empty card and loading state at all and load insight data in the background to be sure that we still provide the most relevant data.
So on the second and further renders it works in this way
- Revisit the dashboard page
- See cached insights without loading state
- But in the background, we're fetching recent data for insights on the page. This step requires some UX input
- When insights background fetching is over update insights chart if needed.
Problem
We probably need to introduce another loading state to notify users that they're looking at cached data and real data might be different compared with cached (I think it's a corner case but still)