From 2d8b6a6c3fa651a080ac2e4c73cf518ca7c277c3 Mon Sep 17 00:00:00 2001 From: LoV432 Date: Tue, 14 Nov 2023 00:36:51 +0500 Subject: [PATCH] keep all connection logs updated --- .../DashboardCardTotalDisconnectTime.client.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/components/dashboard/DashboardCardTotalDisconnectTime.client.tsx b/app/components/dashboard/DashboardCardTotalDisconnectTime.client.tsx index 84ff5e3..37baa9b 100644 --- a/app/components/dashboard/DashboardCardTotalDisconnectTime.client.tsx +++ b/app/components/dashboard/DashboardCardTotalDisconnectTime.client.tsx @@ -25,6 +25,21 @@ export default function DashboardCardTotalDisconnectTime({ connectionLogsListModalRef.current?.showModal(); } } + + useEffect(() => { + const interval = setInterval(() => { + const getNewLogs = fetch('/api/get-connection-logs'); + getNewLogs + .then((response) => response.json()) + .then((data: connectionLogsList) => { + setHumanReadableDisconnectedTime( + connectionLogsListToHumanFormat(data) + ); + setBackgroundColor(dashboardColor(humanReadableDisconnectedTime)); + }); + }, 3000); + return () => clearInterval(interval); + }, []); return ( <>