()
| 65 | |
| 66 | const interval = window.setInterval(refresh, POLL_MS) |
| 67 | const refreshWhenVisible = () => { |
| 68 | if (document.visibilityState === 'visible') { |
| 69 | void refresh() |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | if (pauseWhenHidden) { |
| 74 | document.addEventListener('visibilitychange', refreshWhenVisible) |