Do health check on page initial load
This commit is contained in:
@@ -25,6 +25,7 @@ function App() {
|
|||||||
const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false)
|
const [apiKeyAlertOpen, setApiKeyAlertOpen] = useState(false)
|
||||||
const [initializing, setInitializing] = useState(true) // Add initializing state
|
const [initializing, setInitializing] = useState(true) // Add initializing state
|
||||||
const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode
|
const versionCheckRef = useRef(false); // Prevent duplicate calls in Vite dev mode
|
||||||
|
const healthCheckInitializedRef = useRef(false); // Prevent duplicate health checks in Vite dev mode
|
||||||
|
|
||||||
const handleApiKeyAlertOpenChange = useCallback((open: boolean) => {
|
const handleApiKeyAlertOpenChange = useCallback((open: boolean) => {
|
||||||
setApiKeyAlertOpen(open)
|
setApiKeyAlertOpen(open)
|
||||||
@@ -70,6 +71,14 @@ function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// On first mount or when enableHealthCheck becomes true and apiKeyAlertOpen is false,
|
||||||
|
// perform an immediate health check
|
||||||
|
if (!healthCheckInitializedRef.current) {
|
||||||
|
healthCheckInitializedRef.current = true;
|
||||||
|
// Immediate health check on first load
|
||||||
|
performHealthCheck();
|
||||||
|
}
|
||||||
|
|
||||||
// Set interval for periodic execution
|
// Set interval for periodic execution
|
||||||
const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
|
const interval = setInterval(performHealthCheck, healthCheckInterval * 1000);
|
||||||
return () => clearInterval(interval);
|
return () => clearInterval(interval);
|
||||||
|
Reference in New Issue
Block a user