fix: check server health on tab visibility change for mobile recovery

This commit is contained in:
SnapOtter
2026-06-05 21:45:27 +08:00
parent 005fe1d982
commit fbc70272dd
@@ -14,8 +14,15 @@ export function useConnectionMonitor() {
}
};
const handleVisibilityChange = () => {
if (document.visibilityState === "visible") {
store.getState().checkHealth();
}
};
window.addEventListener("offline", handleOffline);
window.addEventListener("online", handleOnline);
document.addEventListener("visibilitychange", handleVisibilityChange);
store.getState().checkHealth();
@@ -48,6 +55,7 @@ export function useConnectionMonitor() {
return () => {
window.removeEventListener("offline", handleOffline);
window.removeEventListener("online", handleOnline);
document.removeEventListener("visibilitychange", handleVisibilityChange);
store.getState().stopPolling();
unsubscribe();
};