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>();
useEffect(() => {
if (reloadInterval == -1) {
return;
}
setKey(Date.now());
return () => {
@ -34,6 +38,10 @@ export default function AutoUpdatingCameraImage({
}, [reloadInterval]);
const handleLoad = useCallback(() => {
if (reloadInterval == -1) {
return;
}
const loadTime = Date.now() - key;
if (showFps) {

View File

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