Initial commit: Brachnha Insight project setup
- Next.js 14+ with App Router and TypeScript - Tailwind CSS and ShadCN UI styling - Zustand state management - Dexie.js for IndexedDB (local-first data) - Auth.js v5 for authentication - BMAD framework integration Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
39
src/components/features/pwa/PWAInitializer.tsx
Normal file
39
src/components/features/pwa/PWAInitializer.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { SyncManager } from '@/services/sync-manager';
|
||||
import { InstallPromptService } from '@/services/install-prompt-service';
|
||||
import { useOfflineStore } from '@/lib/store/offline-store';
|
||||
|
||||
export function PWAInitializer() {
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
// Story 3.3: Initialize offline network listeners
|
||||
SyncManager.startNetworkListener();
|
||||
|
||||
// Update online status when network changes
|
||||
const updateOnlineStatus = () => {
|
||||
const isOnline = SyncManager.isOnline();
|
||||
useOfflineStore.getState().setOnlineStatus(isOnline);
|
||||
};
|
||||
|
||||
window.addEventListener('online', updateOnlineStatus);
|
||||
window.addEventListener('offline', updateOnlineStatus);
|
||||
|
||||
// Initial status check
|
||||
updateOnlineStatus();
|
||||
|
||||
// Story 3.4: Initialize install prompt service
|
||||
InstallPromptService.initialize();
|
||||
|
||||
console.log('[PWAInitializer] Services initialized');
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('online', updateOnlineStatus);
|
||||
window.removeEventListener('offline', updateOnlineStatus);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user