mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-04-03 22:04:53 +03:00
fix setLastUpdated being called inside useMemo
this triggered a setState-during-render warning, so moved to a useEffect
This commit is contained in:
parent
dd6410fd5a
commit
76ecee92eb
@ -1,7 +1,7 @@
|
|||||||
import { CombinedStorageGraph } from "@/components/graph/CombinedStorageGraph";
|
import { CombinedStorageGraph } from "@/components/graph/CombinedStorageGraph";
|
||||||
import { StorageGraph } from "@/components/graph/StorageGraph";
|
import { StorageGraph } from "@/components/graph/StorageGraph";
|
||||||
import { FrigateStats } from "@/types/stats";
|
import { FrigateStats } from "@/types/stats";
|
||||||
import { useMemo } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
@ -56,9 +56,14 @@ export default function StorageMetrics({
|
|||||||
Object.values(cameraStorage).forEach(
|
Object.values(cameraStorage).forEach(
|
||||||
(cam) => (totalStorage.camera += cam.usage),
|
(cam) => (totalStorage.camera += cam.usage),
|
||||||
);
|
);
|
||||||
setLastUpdated(Date.now() / 1000);
|
|
||||||
return totalStorage;
|
return totalStorage;
|
||||||
}, [cameraStorage, stats, setLastUpdated]);
|
}, [cameraStorage, stats]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (totalStorage) {
|
||||||
|
setLastUpdated(Math.floor(Date.now() / 1000));
|
||||||
|
}
|
||||||
|
}, [totalStorage, setLastUpdated]);
|
||||||
|
|
||||||
// recordings summary
|
// recordings summary
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user