diff --git a/web/src/components/DebugCamera.jsx b/web/src/components/DebugCamera.jsx
new file mode 100644
index 000000000..9c4d67f73
--- /dev/null
+++ b/web/src/components/DebugCamera.jsx
@@ -0,0 +1,74 @@
+import { h } from 'preact';
+import Link from './Link';
+import Switch from './Switch';
+import { useCallback, useMemo } from 'preact/hooks';
+import { usePersistence } from '../context';
+import AutoUpdatingCameraImage from './AutoUpdatingCameraImage';
+
+const emptyObject = Object.freeze({});
+
+export function DebugCamera({ camera }) {
+ const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);
+
+ const handleSetOption = useCallback(
+ (id, value) => {
+ const newOptions = { ...options, [id]: value };
+ setOptions(newOptions);
+ },
+ [options, setOptions]
+ );
+
+ const searchParams = useMemo(
+ () =>
+ new URLSearchParams(
+ Object.keys(options).reduce((memo, key) => {
+ memo.push([key, options[key] === true ? '1' : '0']);
+ return memo;
+ }, [])
+ ),
+ [options]
+ );
+
+ const optionContent = (
+
+
+
+
+
+
+
+ Mask & Zone creator
+
+ );
+
+ return (
+
+ );
+}
diff --git a/web/src/components/HistoryViewer.jsx b/web/src/components/HistoryViewer.jsx
index 69b61a4e1..94a6cebd6 100644
--- a/web/src/components/HistoryViewer.jsx
+++ b/web/src/components/HistoryViewer.jsx
@@ -76,7 +76,7 @@ export default function HistoryViewer({ camera }) {
/>
);
- }, [currentEvent, apiHost, camera]);
+ }, [currentEvent, apiHost, camera, videoRef]);
return (
diff --git a/web/src/routes/Camera_V2.jsx b/web/src/routes/Camera_V2.jsx
index 5e2039d91..5326f9208 100644
--- a/web/src/routes/Camera_V2.jsx
+++ b/web/src/routes/Camera_V2.jsx
@@ -1,17 +1,12 @@
import { h, Fragment } from 'preact';
-import AutoUpdatingCameraImage from '../components/AutoUpdatingCameraImage';
import JSMpegPlayer from '../components/JSMpegPlayer';
import Heading from '../components/Heading';
-import Link from '../components/Link';
-import Switch from '../components/Switch';
-import { usePersistence } from '../context';
-import { useCallback, useEffect, useMemo, useState } from 'preact/hooks';
+import { useState } from 'preact/hooks';
import { useConfig } from '../api';
import { Tabs, TextTab } from '../components/Tabs';
import { LiveChip } from '../components/LiveChip';
import HistoryViewer from '../components/HistoryViewer';
-
-const emptyObject = Object.freeze({});
+import { DebugCamera } from '../components/DebugCamera';
export default function Camera({ camera }) {
const { data: config } = useConfig();
@@ -20,89 +15,23 @@ export default function Camera({ camera }) {
const cameraConfig = config?.cameras[camera];
const liveWidth = Math.round(cameraConfig.live.height * (cameraConfig.detect.width / cameraConfig.detect.height));
- const [options, setOptions] = usePersistence(`${camera}-feed`, emptyObject);
- const handleSetOption = useCallback(
- (id, value) => {
- const newOptions = { ...options, [id]: value };
- setOptions(newOptions);
- },
- [options, setOptions]
- );
-
- const searchParams = useMemo(
- () =>
- new URLSearchParams(
- Object.keys(options).reduce((memo, key) => {
- memo.push([key, options[key] === true ? '1' : '0']);
- return memo;
- }, [])
- ),
- [options]
- );
-
- const optionContent = (
-
-
-
-
-
-
-
- Mask & Zone creator
-
- );
-
- let renderPlayer;
-
- switch (playerType) {
- case 'live':
- renderPlayer = (
+ const RenderPlayer = () => {
+ if (playerType === 'live') {
+ return (
);
- break;
- case 'history':
- renderPlayer = ;
- break;
- case 'debug':
- renderPlayer = (
-
-
- {optionContent}
-
- );
- break;
- default:
- break;
- }
+ } else if (playerType === 'history') {
+ return ;
+ } else if (playerType === 'debug') {
+ return ;
+ }
+ return ;
+ };
const handleTabChange = (index) => {
if (index === 0) {
@@ -130,7 +59,9 @@ export default function Camera({ camera }) {
- {renderPlayer}
+
+
+