()
| 45 | let isMounted = true |
| 46 | |
| 47 | async function refresh() { |
| 48 | if (pauseWhenHidden && document.visibilityState === 'hidden') { |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | try { |
| 53 | const response = await fetch('/api/live', { cache: 'no-store' }) |
| 54 | if (response.ok && isMounted) { |
| 55 | setStats((await response.json()) as FreebuffLiveStats) |
| 56 | } |
| 57 | } catch { |
| 58 | // Keep the previous snapshot if a transient refresh fails. |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if (refreshOnMount) { |
| 63 | void refresh() |
no test coverage detected