forked from Github/frigate
Further improve event loading (#10949)
* Further improve loading * Add document titles to pages * Cleanup
This commit is contained in:
@@ -6,18 +6,37 @@ import { FrigateConfig } from "@/types/frigateConfig";
|
||||
import LiveBirdseyeView from "@/views/live/LiveBirdseyeView";
|
||||
import LiveCameraView from "@/views/live/LiveCameraView";
|
||||
import LiveDashboardView from "@/views/live/LiveDashboardView";
|
||||
import { useMemo } from "react";
|
||||
import { useEffect, useMemo } from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
function Live() {
|
||||
const { data: config } = useSWR<FrigateConfig>("config");
|
||||
|
||||
// selection
|
||||
|
||||
const [selectedCameraName, setSelectedCameraName] = useHashState();
|
||||
const [cameraGroup] = usePersistedOverlayState(
|
||||
"cameraGroup",
|
||||
"default" as string,
|
||||
);
|
||||
|
||||
// document title
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedCameraName) {
|
||||
const capitalized = selectedCameraName
|
||||
.split("_")
|
||||
.map((text) => text[0].toUpperCase() + text.substring(1));
|
||||
document.title = `${capitalized.join(" ")} - Live - Frigate`;
|
||||
} else if (cameraGroup && cameraGroup != "default") {
|
||||
document.title = `${cameraGroup[0].toUpperCase()}${cameraGroup.substring(1)} - Live - Frigate`;
|
||||
} else {
|
||||
document.title = "Live - Frigate";
|
||||
}
|
||||
}, [cameraGroup, selectedCameraName]);
|
||||
|
||||
// settings
|
||||
|
||||
const includesBirdseye = useMemo(() => {
|
||||
if (config && cameraGroup && cameraGroup != "default") {
|
||||
return config.camera_groups[cameraGroup].cameras.includes("birdseye");
|
||||
|
||||
Reference in New Issue
Block a user