import { useEffect } from 'react'; import { DeviceRestore } from './DeviceRestore'; import { AlertIcon, ShieldIcon, XIcon } from './icons'; interface Props { open: boolean; userId: string; onClose: () => void; } // Modal wrapper around DeviceRestore for the already-signed-in case. A // successful restore swaps the local device-identity for the one embedded // in the backup string — the app then hard-reloads so every hook // re-initialises against the restored keys (simpler than invalidating // supabase-realtime subscriptions, stronghold caches, livekit rooms, etc. // individually). export function BackupRestoreDialog({ open, userId, onClose }: Props) { useEffect(() => { if (!open) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', onKey); const prev = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { window.removeEventListener('keydown', onKey); document.body.style.overflow = prev; }; }, [open, onClose]); if (!open) return null; return (
Restore ersetzt das aktuelle Gerät durch das aus dem Backup. Die App lädt danach neu. Nachrichten, die auf diesem Gerät seit dem Backup eingegangen sind, sind erst wieder lesbar, nachdem Peer-Geräte den Conversation-Key erneut für die wiederhergestellte Device-ID wrappen.