From a862ba8348cc5d689453abe8639ebcfe10a87f99 Mon Sep 17 00:00:00 2001 From: Paul Armstrong Date: Wed, 20 Jan 2021 09:01:00 -0800 Subject: [PATCH] feat(web): AutoUpdatingCameraImage to replace MJPEG feed --- web/src/Camera.jsx | 8 ++---- web/src/CameraMap.jsx | 4 +-- .../components/AutoUpdatingCameraImage.jsx | 27 +++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 web/src/components/AutoUpdatingCameraImage.jsx diff --git a/web/src/Camera.jsx b/web/src/Camera.jsx index 8d773cd3f..9136dbd37 100644 --- a/web/src/Camera.jsx +++ b/web/src/Camera.jsx @@ -1,4 +1,5 @@ import { h } from 'preact'; +import AutoUpdatingCameraImage from './components/AutoUpdatingCameraImage'; import Box from './components/Box'; import Heading from './components/Heading'; import Link from './components/Link'; @@ -36,12 +37,7 @@ export default function Camera({ camera, url }) {
{camera} - + diff --git a/web/src/CameraMap.jsx b/web/src/CameraMap.jsx index fce285481..b84a8137c 100644 --- a/web/src/CameraMap.jsx +++ b/web/src/CameraMap.jsx @@ -213,7 +213,7 @@ ${Object.keys(objectMaskPoints) ); return ( -
+
{camera} mask & zone creator @@ -226,7 +226,7 @@ ${Object.keys(objectMaskPoints)
- + { + const timeoutId = setTimeout(() => { + setKey(Date.now()); + }, 500); + return () => { + clearTimeout(timeoutId); + }; + }, [key, searchParams]); + + return ( + {`Auto-updating + ); +}