mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-21 17:07:47 +02:00
fix(site): discard pending history when switching to live charts (#2333)
This commit is contained in:
@@ -171,6 +171,7 @@ export function useSystemData(id: string) {
|
|||||||
// get stats when system "changes." (Not just system to system,
|
// get stats when system "changes." (Not just system to system,
|
||||||
// also when new info comes in via systemManager realtime connection, indicating an update)
|
// also when new info comes in via systemManager realtime connection, indicating an update)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
const requestId = ++statsRequestId.current
|
||||||
if (!system.id || !chartTime || chartTime === "1m") {
|
if (!system.id || !chartTime || chartTime === "1m") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -179,7 +180,6 @@ export function useSystemData(id: string) {
|
|||||||
const { expectedInterval } = chartTimeData[chartTime]
|
const { expectedInterval } = chartTimeData[chartTime]
|
||||||
const ss_cache_key = `${systemId}_${chartTime}_system_stats`
|
const ss_cache_key = `${systemId}_${chartTime}_system_stats`
|
||||||
const cs_cache_key = `${systemId}_${chartTime}_container_stats`
|
const cs_cache_key = `${systemId}_${chartTime}_container_stats`
|
||||||
const requestId = ++statsRequestId.current
|
|
||||||
|
|
||||||
const cachedSystemStats = cache.get(ss_cache_key) as SystemStatsRecord[] | undefined
|
const cachedSystemStats = cache.get(ss_cache_key) as SystemStatsRecord[] | undefined
|
||||||
const cachedContainerData = cache.get(cs_cache_key) as ChartData["containerData"] | undefined
|
const cachedContainerData = cache.get(cs_cache_key) as ChartData["containerData"] | undefined
|
||||||
@@ -203,7 +203,7 @@ export function useSystemData(id: string) {
|
|||||||
getStats<SystemStatsRecord>("system_stats", systemId, chartTime),
|
getStats<SystemStatsRecord>("system_stats", systemId, chartTime),
|
||||||
getStats<ContainerStatsRecord>("container_stats", systemId, chartTime),
|
getStats<ContainerStatsRecord>("container_stats", systemId, chartTime),
|
||||||
]).then(([systemStats, containerStats]) => {
|
]).then(([systemStats, containerStats]) => {
|
||||||
// If another request has been made since this one, ignore the results
|
// Ignore responses for a previous system or chart time
|
||||||
if (requestId !== statsRequestId.current) {
|
if (requestId !== statsRequestId.current) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user