feat(platform): poll topbar link health
This commit is contained in:
@@ -15,17 +15,25 @@ export default function App() {
|
|||||||
const [activeVin, setActiveVin] = useState('LB9A32A24R0LS1426');
|
const [activeVin, setActiveVin] = useState('LB9A32A24R0LS1426');
|
||||||
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
|
const [linkIssueCount, setLinkIssueCount] = useState<number | null>(null);
|
||||||
|
|
||||||
const refreshOpsHealth = useCallback(() => {
|
const refreshOpsHealth = useCallback((showError = true) => {
|
||||||
return api.opsHealth()
|
return api.opsHealth()
|
||||||
.then((health) => {
|
.then((health) => {
|
||||||
setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length);
|
setLinkIssueCount(health.linkHealth.filter((item) => item.status !== 'ok').length);
|
||||||
return health;
|
return health;
|
||||||
})
|
})
|
||||||
.catch((error: Error) => Toast.error(error.message));
|
.catch((error: Error) => {
|
||||||
|
if (showError) {
|
||||||
|
Toast.error(error.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshOpsHealth();
|
refreshOpsHealth();
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
refreshOpsHealth(false);
|
||||||
|
}, 60000);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
}, [refreshOpsHealth]);
|
}, [refreshOpsHealth]);
|
||||||
|
|
||||||
const openVehicle = (vin: string) => {
|
const openVehicle = (vin: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user