fix: Add Background Sync API type declarations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2025-12-29 01:43:47 +01:00
parent 9c618cffb7
commit aa501b1778
1 changed files with 10 additions and 1 deletions

View File

@ -2,6 +2,15 @@
import { useEffect, useCallback, useRef } from 'react';
// Background Sync API types (not in default TypeScript libs)
interface SyncManager {
register(tag: string): Promise<void>;
}
interface ServiceWorkerRegistrationWithSync extends ServiceWorkerRegistration {
sync: SyncManager;
}
interface UseServiceWorkerMessagesOptions {
onLocationRequest?: () => void;
onLocationSync?: () => void;
@ -51,7 +60,7 @@ export function useServiceWorkerMessages(options: UseServiceWorkerMessagesOption
}
try {
const registration = await navigator.serviceWorker.ready;
const registration = await navigator.serviceWorker.ready as ServiceWorkerRegistrationWithSync;
await registration.sync.register('rmaps-location-sync');
console.log('[App] Background sync registered');
return true;