From 483d64e41924c4e29b36f4c1b146403f3cb1d6d1 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 3 Apr 2024 10:56:04 -0600 Subject: [PATCH] Don't show warning for disabled cameras (#10811) --- web/src/components/Statusbar.tsx | 5 ++++- web/src/hooks/use-stats.ts | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/web/src/components/Statusbar.tsx b/web/src/components/Statusbar.tsx index 52bbe3114..a210db508 100644 --- a/web/src/components/Statusbar.tsx +++ b/web/src/components/Statusbar.tsx @@ -87,7 +87,10 @@ export default function Statusbar() {
{potentialProblems.map((prob) => ( -
+
{prob.text}
diff --git a/web/src/hooks/use-stats.ts b/web/src/hooks/use-stats.ts index 57461d063..18346538d 100644 --- a/web/src/hooks/use-stats.ts +++ b/web/src/hooks/use-stats.ts @@ -1,7 +1,11 @@ +import { FrigateConfig } from "@/types/frigateConfig"; import { FrigateStats, PotentialProblem } from "@/types/stats"; import { useMemo } from "react"; +import useSWR from "swr"; export default function useStats(stats: FrigateStats | undefined) { + const { data: config } = useSWR("config"); + const potentialProblems = useMemo(() => { const problems: PotentialProblem[] = []; @@ -26,7 +30,11 @@ export default function useStats(stats: FrigateStats | undefined) { // check for offline cameras Object.entries(stats["cameras"]).forEach(([name, cam]) => { - if (cam["camera_fps"] == 0) { + if (!config) { + return; + } + + if (config.cameras[name].enabled && cam["camera_fps"] == 0) { problems.push({ text: `${name.replaceAll("_", " ")} is offline`, color: "text-danger", @@ -59,7 +67,7 @@ export default function useStats(stats: FrigateStats | undefined) { }); return problems; - }, [stats]); + }, [config, stats]); return { potentialProblems }; }