feat(dashboard): keep throughput cards up to date

Refresh project dashboard data every 60 seconds so 24h throughput and health stats stay current even without new events.

closes #7
This commit is contained in:
thibaud-lclr 2026-04-17 08:49:32 +02:00
parent d75695ffe6
commit 5dbaa3c717

View file

@ -1,5 +1,5 @@
import { listen } from "@tauri-apps/api/event";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import { useParams, Link, useNavigate } from "react-router-dom";
import {
getProject,
@ -67,7 +67,7 @@ export default function ProjectDashboard() {
setActivity((prev) => [item, ...prev].slice(0, 30));
}
async function loadData() {
const loadData = useCallback(async () => {
if (!projectId) return;
const [proj, trks, tkts, stats] = await Promise.all([
getProject(projectId),
@ -79,11 +79,21 @@ export default function ProjectDashboard() {
setTrackers(trks);
setTickets(tkts);
setThroughput(stats);
}
}, [projectId]);
useEffect(() => {
loadData();
}, [projectId]);
void loadData();
}, [loadData]);
useEffect(() => {
if (!projectId) return;
const intervalId = window.setInterval(() => {
void loadData();
}, 60_000);
return () => window.clearInterval(intervalId);
}, [projectId, loadData]);
useEffect(() => {
if (!projectId) return;