feat(web): pending-message orchestrator (TTL discard, deferred send, online retry)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export function useNetworkStatus(): boolean {
|
||||
const [online, setOnline] = useState<boolean>(navigator.onLine);
|
||||
useEffect(() => {
|
||||
const on = () => setOnline(true);
|
||||
const off = () => setOnline(false);
|
||||
window.addEventListener('online', on);
|
||||
window.addEventListener('offline', off);
|
||||
return () => {
|
||||
window.removeEventListener('online', on);
|
||||
window.removeEventListener('offline', off);
|
||||
};
|
||||
}, []);
|
||||
return online;
|
||||
}
|
||||
Reference in New Issue
Block a user