insights: skip get insights calls when insight card is not visible
Created by: chwarwick
This re-enables insight polling by default but only polls when the insight card is visible. I also slightly slowed down the polling rate.
Some notes:
stopPolling
is safe to call as often as you want it's a noop if you are not polling
startPolling
if called multiple time causes the previous interval to get canceled a new one to start, so we need to be careful not to call it over and over.
resolves https://github.com/sourcegraph/sourcegraph/issues/38425
Test plan
- Created 3 rows of insights (one permanently in a processing state) and shrunk screen so that only 1 row was visible at a time
- Scrolled and monitored that network requests occurred when row appeared
- Verified polling stoped when insight left screen and resumed when it reentered
- Verified changing filter and sorting values correctly updated ui
- Verified setting
insight-polling-enabled
= false ensured that no polling occurred.
App preview:
Check out the client app preview documentation to learn more.