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:
parent
d75695ffe6
commit
5dbaa3c717
1 changed files with 15 additions and 5 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { listen } from "@tauri-apps/api/event";
|
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 { useParams, Link, useNavigate } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
getProject,
|
getProject,
|
||||||
|
|
@ -67,7 +67,7 @@ export default function ProjectDashboard() {
|
||||||
setActivity((prev) => [item, ...prev].slice(0, 30));
|
setActivity((prev) => [item, ...prev].slice(0, 30));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadData() {
|
const loadData = useCallback(async () => {
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
const [proj, trks, tkts, stats] = await Promise.all([
|
const [proj, trks, tkts, stats] = await Promise.all([
|
||||||
getProject(projectId),
|
getProject(projectId),
|
||||||
|
|
@ -79,11 +79,21 @@ export default function ProjectDashboard() {
|
||||||
setTrackers(trks);
|
setTrackers(trks);
|
||||||
setTickets(tkts);
|
setTickets(tkts);
|
||||||
setThroughput(stats);
|
setThroughput(stats);
|
||||||
}
|
}, [projectId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadData();
|
void loadData();
|
||||||
}, [projectId]);
|
}, [loadData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!projectId) return;
|
||||||
|
|
||||||
|
const intervalId = window.setInterval(() => {
|
||||||
|
void loadData();
|
||||||
|
}, 60_000);
|
||||||
|
|
||||||
|
return () => window.clearInterval(intervalId);
|
||||||
|
}, [projectId, loadData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue