From 4572cfe2b7afc79bfd25ce44325224d9b956a98a Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:55:04 -0500 Subject: [PATCH] Don't display offline message in live player if camera is restreamed --- web/src/components/player/LivePlayer.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index ec24d255f..7d4b85b02 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -1,5 +1,5 @@ import WebRtcPlayer from "./WebRTCPlayer"; -import { CameraConfig } from "@/types/frigateConfig"; +import { CameraConfig, FrigateConfig } from "@/types/frigateConfig"; import AutoUpdatingCameraImage from "../camera/AutoUpdatingCameraImage"; import ActivityIndicator from "../indicators/activity-indicator"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; @@ -20,6 +20,7 @@ import { cn } from "@/lib/utils"; import { TbExclamationCircle } from "react-icons/tb"; import { TooltipPortal } from "@radix-ui/react-tooltip"; import { baseUrl } from "@/api/baseUrl"; +import useSWR from "swr"; type LivePlayerProps = { cameraRef?: (ref: HTMLDivElement | null) => void; @@ -58,7 +59,9 @@ export default function LivePlayer({ onError, onResetLiveMode, }: LivePlayerProps) { + const { data: config } = useSWR("config"); const internalContainerRef = useRef(null); + // camera activity const { activeMotion, activeTracking, objects, offline } = @@ -147,6 +150,14 @@ export default function LivePlayer({ setLiveReady(true); }, []); + const isRestreamed = useMemo( + () => + cameraConfig && + config && + Object.keys(config.go2rtc.streams || {}).includes(cameraConfig.name), + [cameraConfig, config], + ); + if (!cameraConfig) { return ; } @@ -298,7 +309,7 @@ export default function LivePlayer({ /> - {offline && !showStillWithoutActivity && ( + {offline && !showStillWithoutActivity && !isRestreamed && (

{capitalizeFirstLetter(cameraConfig.name)} is offline