Initial scaffold: React+TS+Vite frontend, FastAPI backend, config system

This commit is contained in:
root
2026-02-25 21:57:36 -06:00
commit 11eab66e9d
45 changed files with 4508 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import { useEffect, useRef } from 'react';
import { AlertWebSocket } from '@/services/alerts';
import { useAlertStore } from '@/stores/alertStore';
import { useConfigStore } from '@/stores/configStore';
export function useAlerts() {
const wsRef = useRef<AlertWebSocket | null>(null);
const config = useConfigStore((s) => s.config);
const { showAlert, isSuppressed, activeAlert } = useAlertStore();
useEffect(() => {
if (!config?.alerts.enabled) return;
const ws = new AlertWebSocket();
wsRef.current = ws;
const unsub = ws.subscribe((event) => {
// Don't show if there's already an active alert
if (useAlertStore.getState().activeAlert) return;
// Check suppression
if (isSuppressed(event.camera, config.alerts.suppression_seconds)) return;
showAlert(event);
});
ws.connect();
return () => {
unsub();
ws.disconnect();
wsRef.current = null;
};
}, [config?.alerts.enabled]);
}