updated image loading

This commit is contained in:
2025-08-22 10:38:28 +01:00
parent 44af1b21b7
commit 5ededd8e05
15 changed files with 258 additions and 120 deletions

View File

@@ -2,6 +2,8 @@ import { useQuery } from "@tanstack/react-query";
import { useRef } from "react";
const apiUrl = import.meta.env.VITE_BASEURL;
const FAST_MS = 200; // tab visible
const SLOW_MS = 2000; // tab hidden
async function fetchOverviewImage(cameraSide: string) {
const response = await fetch(`${apiUrl}${cameraSide}-preview`);
@@ -14,7 +16,11 @@ export function useOverviewVideo() {
const { isPending, isError, data } = useQuery({
queryKey: ["overviewVideo"],
queryFn: () => fetchOverviewImage("CameraFront"),
refetchInterval: 500,
// refetchInterval: () =>
// typeof document !== "undefined" && document.visibilityState === "hidden"
// ? SLOW_MS
// : FAST_MS,
// refetchIntervalInBackground: false,
});
if (isPending) return;