Don't reload when window not visible

This commit is contained in:
Nicolas Mowen 2024-02-12 14:13:21 -07:00
parent 89c06068a9
commit adc103ccc8
2 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,10 @@ export default function AutoUpdatingCameraImage({
const [timeoutId, setTimeoutId] = useState<NodeJS.Timeout>(); const [timeoutId, setTimeoutId] = useState<NodeJS.Timeout>();
useEffect(() => { useEffect(() => {
if (reloadInterval == -1) {
return;
}
setKey(Date.now()); setKey(Date.now());
return () => { return () => {
@ -34,6 +38,10 @@ export default function AutoUpdatingCameraImage({
}, [reloadInterval]); }, [reloadInterval]);
const handleLoad = useCallback(() => { const handleLoad = useCallback(() => {
if (reloadInterval == -1) {
return;
}
const loadTime = Date.now() - key; const loadTime = Date.now() - key;
if (showFps) { if (showFps) {

View File

@ -62,6 +62,10 @@ export default function LivePlayer({
// camera still state // camera still state
const stillReloadInterval = useMemo(() => { const stillReloadInterval = useMemo(() => {
if (!windowVisible) {
return -1; // no reason to update the image when the window is not visible
}
if (liveReady) { if (liveReady) {
return 60000; return 60000;
} }