mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-07 11:45:24 +03:00
Update recent events correctly
This commit is contained in:
parent
04a0615ab8
commit
cc95fd9901
@ -21,8 +21,9 @@ function ConfigEditor() {
|
|||||||
const [success, setSuccess] = useState<string | undefined>();
|
const [success, setSuccess] = useState<string | undefined>();
|
||||||
const [error, setError] = useState<string | undefined>();
|
const [error, setError] = useState<string | undefined>();
|
||||||
|
|
||||||
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>();
|
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
|
||||||
const modelRef = useRef<monaco.editor.IEditorModel | null>();
|
const modelRef = useRef<monaco.editor.IEditorModel | null>(null);
|
||||||
|
const configRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
|
||||||
const onHandleSaveConfig = useCallback(
|
const onHandleSaveConfig = useCallback(
|
||||||
async (save_option: SaveOptions) => {
|
async (save_option: SaveOptions) => {
|
||||||
@ -72,6 +73,7 @@ function ConfigEditor() {
|
|||||||
|
|
||||||
if (modelRef.current != null) {
|
if (modelRef.current != null) {
|
||||||
// we don't need to recreate the editor if it already exists
|
// we don't need to recreate the editor if it already exists
|
||||||
|
editorRef.current?.layout();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,9 +99,9 @@ function ConfigEditor() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const container = document.getElementById("container");
|
const container = configRef.current;
|
||||||
|
|
||||||
if (container != undefined) {
|
if (container != null) {
|
||||||
editorRef.current = monaco.editor.create(container, {
|
editorRef.current = monaco.editor.create(container, {
|
||||||
language: "yaml",
|
language: "yaml",
|
||||||
model: modelRef.current,
|
model: modelRef.current,
|
||||||
@ -107,6 +109,12 @@ function ConfigEditor() {
|
|||||||
theme: theme == "dark" ? "vs-dark" : "vs-light",
|
theme: theme == "dark" ? "vs-dark" : "vs-light",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
configRef.current = null;
|
||||||
|
editorRef.current = null;
|
||||||
|
modelRef.current = null;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
@ -149,7 +157,7 @@ function ConfigEditor() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div id="container" className="h-full mt-2" />
|
<div ref={configRef} className="h-full mt-2" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,12 +23,9 @@ import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
|||||||
|
|
||||||
export function Dashboard() {
|
export function Dashboard() {
|
||||||
const { data: config } = useSWR<FrigateConfig>("config");
|
const { data: config } = useSWR<FrigateConfig>("config");
|
||||||
|
const now = new Date();
|
||||||
const recentTimestamp = useMemo(() => {
|
now.setMinutes(now.getMinutes() - 30, 0, 0);
|
||||||
const now = new Date();
|
const recentTimestamp = now.getTime() / 1000;
|
||||||
now.setMinutes(now.getMinutes() - 30);
|
|
||||||
return now.getTime() / 1000;
|
|
||||||
}, []);
|
|
||||||
const { data: events, mutate: updateEvents } = useSWR<FrigateEvent[]>([
|
const { data: events, mutate: updateEvents } = useSWR<FrigateEvent[]>([
|
||||||
"events",
|
"events",
|
||||||
{ limit: 10, after: recentTimestamp },
|
{ limit: 10, after: recentTimestamp },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user