mirror of
https://github.com/dergigi/boris.git
synced 2026-02-16 12:34:41 +01:00
- Add web app manifest with proper metadata and icon support - Configure vite-plugin-pwa with injectManifest strategy - Migrate service worker to Workbox with precaching and runtime caching - Add runtime caching for cross-origin images (preserves existing behavior) - Add runtime caching for cross-origin article HTML for offline reading - Create PWA install hook and UI component in settings - Add online/offline status monitoring and toast notifications - Add service worker update notifications - Add placeholder PWA icons (192x192, 512x512, maskable variants) - Update HTML with manifest link and theme-color meta tag - Preserve existing relay/airplane mode functionality (WebSockets not intercepted) The app now passes PWA installability criteria while maintaining all existing offline functionality. Icons should be replaced with proper branded designs.
29 lines
649 B
TypeScript
29 lines
649 B
TypeScript
import { useState, useEffect } from 'react'
|
|
|
|
export function useOnlineStatus() {
|
|
const [isOnline, setIsOnline] = useState(navigator.onLine)
|
|
|
|
useEffect(() => {
|
|
const handleOnline = () => {
|
|
console.log('🌐 Back online')
|
|
setIsOnline(true)
|
|
}
|
|
|
|
const handleOffline = () => {
|
|
console.log('📴 Gone offline')
|
|
setIsOnline(false)
|
|
}
|
|
|
|
window.addEventListener('online', handleOnline)
|
|
window.addEventListener('offline', handleOffline)
|
|
|
|
return () => {
|
|
window.removeEventListener('online', handleOnline)
|
|
window.removeEventListener('offline', handleOffline)
|
|
}
|
|
}, [])
|
|
|
|
return isOnline
|
|
}
|
|
|