mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
Use hash state for system pages
This commit is contained in:
parent
8c610bea49
commit
7e98d8c687
@ -11,6 +11,7 @@ import { FaVideo } from "react-icons/fa";
|
|||||||
import Logo from "@/components/Logo";
|
import Logo from "@/components/Logo";
|
||||||
import useOptimisticState from "@/hooks/use-optimistic-state";
|
import useOptimisticState from "@/hooks/use-optimistic-state";
|
||||||
import CameraMetrics from "@/views/system/CameraMetrics";
|
import CameraMetrics from "@/views/system/CameraMetrics";
|
||||||
|
import { useHashState } from "@/hooks/use-overlay-state";
|
||||||
|
|
||||||
const metrics = ["general", "storage", "cameras"] as const;
|
const metrics = ["general", "storage", "cameras"] as const;
|
||||||
type SystemMetric = (typeof metrics)[number];
|
type SystemMetric = (typeof metrics)[number];
|
||||||
@ -18,12 +19,18 @@ type SystemMetric = (typeof metrics)[number];
|
|||||||
function System() {
|
function System() {
|
||||||
// stats page
|
// stats page
|
||||||
|
|
||||||
const [page, setPage] = useState<SystemMetric>("general");
|
const [page, setPage] = useHashState<SystemMetric>();
|
||||||
const [pageToggle, setPageToggle] = useOptimisticState(page, setPage, 100);
|
const [pageToggle, setPageToggle] = useOptimisticState(
|
||||||
|
page ?? "general",
|
||||||
|
setPage,
|
||||||
|
100,
|
||||||
|
);
|
||||||
const [lastUpdated, setLastUpdated] = useState<number>(Date.now() / 1000);
|
const [lastUpdated, setLastUpdated] = useState<number>(Date.now() / 1000);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.title = `${pageToggle[0].toUpperCase()}${pageToggle.substring(1)} Stats - Frigate`;
|
if (pageToggle) {
|
||||||
|
document.title = `${pageToggle[0].toUpperCase()}${pageToggle.substring(1)} Stats - Frigate`;
|
||||||
|
}
|
||||||
}, [pageToggle]);
|
}, [pageToggle]);
|
||||||
|
|
||||||
// stats collection
|
// stats collection
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user