From e4aa081e641aa39656d2c2efd4a557473ecf8d33 Mon Sep 17 00:00:00 2001 From: MacRimi Date: Tue, 10 Mar 2026 17:32:18 +0100 Subject: [PATCH] Update health-status-modal.tsx --- AppImage/components/health-status-modal.tsx | 28 ++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/AppImage/components/health-status-modal.tsx b/AppImage/components/health-status-modal.tsx index e9f36f66..29cd843b 100644 --- a/AppImage/components/health-status-modal.tsx +++ b/AppImage/components/health-status-modal.tsx @@ -130,6 +130,9 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu } const response = await fetch(getApiUrl("/api/health/full"), { headers: authHeaders }) + let infoCount = 0 + let dismissedCount = 0 + if (!response.ok) { // Fallback to legacy endpoint const legacyResponse = await fetch(getApiUrl("/api/health/details"), { headers: authHeaders }) @@ -139,18 +142,24 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu setDismissedItems([]) setCustomSuppressions([]) newOverallStatus = data?.overall || "OK" + + // Count INFO categories from legacy data + if (data?.details) { + CATEGORIES.forEach(({ key }) => { + const cat = data.details[key as keyof typeof data.details] + if (cat && cat.status?.toUpperCase() === "INFO") { + infoCount++ + } + }) + } } else { const fullData: FullHealthData = await response.json() setHealthData(fullData.health) setDismissedItems(fullData.dismissed || []) setCustomSuppressions(fullData.custom_suppressions || []) newOverallStatus = fullData.health?.overall || "OK" - } - - // Calculate infoCount: categories with INFO status + dismissed items - let infoCount = 0 - if (response.ok) { - const fullData: FullHealthData = await response.clone().json() + dismissedCount = (fullData.dismissed || []).length + // Count INFO categories if (fullData.health?.details) { CATEGORIES.forEach(({ key }) => { @@ -160,13 +169,14 @@ export function HealthStatusModal({ open, onOpenChange, getApiUrl }: HealthStatu } }) } - // Add dismissed items count - infoCount += (fullData.dismissed || []).length } + // Total info = INFO categories + dismissed items + const totalInfoCount = infoCount + dismissedCount + // Emit event with the FRESH data from the response, not the stale state const event = new CustomEvent("healthStatusUpdated", { - detail: { status: newOverallStatus, infoCount }, + detail: { status: newOverallStatus, infoCount: totalInfoCount }, }) window.dispatchEvent(event) } catch (err) {