mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
Wire OfflineBoundary + OpsListLocal on the eight ops list routes. Local reads the ops mirror with subscribeChanges, applies canonical URL parsers for filter/sort/page, and keeps KPIs/edit/saved-filter writes honest offline. Extract demand/organization list URL modules for client use. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
24 lines
709 B
TypeScript
24 lines
709 B
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
/** Browser online/offline only — matches OfflineBoundary Local trigger. */
|
|
export const useBrowserOffline = (): boolean => {
|
|
const [offline, setOffline] = useState(() =>
|
|
typeof navigator !== 'undefined' ? !navigator.onLine : false,
|
|
)
|
|
|
|
useEffect(() => {
|
|
const onOnline = () => setOffline(false)
|
|
const onOffline = () => setOffline(true)
|
|
setOffline(!navigator.onLine)
|
|
window.addEventListener('online', onOnline)
|
|
window.addEventListener('offline', onOffline)
|
|
return () => {
|
|
window.removeEventListener('online', onOnline)
|
|
window.removeEventListener('offline', onOffline)
|
|
}
|
|
}, [])
|
|
|
|
return offline
|
|
}
|