fix(beszel): address review findings for live streaming
- Skip toReversed() for live data (already chronological from buffer) - Reset live buffer on systemId/integration change to avoid stale data - Throw on unexpected SSE stream end so subscription emits error - Delete unused time-period.ts config (duplicate of server-side config)
This commit is contained in:
4 files changed
+19
-23
No files matched your search
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import type { BeszelContainerStatsRecord, BeszelSystemStatsRecord } from "@homarr/integrations/types";
|
||||
@@ -12,10 +12,20 @@ interface LiveStatsData {
|
||||
containerStats: BeszelContainerStatsRecord[];
|
||||
}
|
||||
|
||||
export const useLiveStats = (integrationIds: string[], systemId: string, includeDocker: boolean, enabled: boolean) => {
|
||||
export const useLiveStats = (
|
||||
integrationIds: string[],
|
||||
systemId: string,
|
||||
includeDocker: boolean,
|
||||
enabled: boolean,
|
||||
) => {
|
||||
const bufferRef = useRef<LiveStatsData>({ systemStats: [], containerStats: [] });
|
||||
const [data, setData] = useState<LiveStatsData | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
bufferRef.current = { systemStats: [], containerStats: [] };
|
||||
setData(null);
|
||||
}, [systemId, enabled, ...integrationIds]);
|
||||
|
||||
const onData = useCallback(
|
||||
(incoming: { stats: BeszelSystemStatsRecord; containerStats: BeszelContainerStatsRecord | null }) => {
|
||||
const buf = bufferRef.current;
|
||||
|
||||
Reference in new issue
Block a user