import { useEffect, useRef, useState } from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { APP_VERSION, RELEASE_NOTES } from '@/lib/version'; import { Sparkles } from 'lucide-react'; import { useAuth } from '@/hooks/useAuth'; import { api } from '@/api'; // Written on close so the dialog doesn't flash during the brief window before // /me resolves on repeat visits. The backend is authoritative; this is a cache. const LS_KEY = `bt-release-seen-${APP_VERSION}`; export function ReleaseNotesDialog() { const { hasNewVersion, setHasNewVersion } = useAuth(); const [open, setOpen] = useState(false); const titleRef = useRef(null); useEffect(() => { if (hasNewVersion) setOpen(true); }, [hasNewVersion]); const handleClose = () => { localStorage.setItem(LS_KEY, '1'); setOpen(false); setHasNewVersion(false); // optimistic — don't wait for the server api.acknowledgeVersion().catch(() => {}); // fire-and-forget const prev = document.activeElement; if (prev?.focus) setTimeout(() => prev.focus(), 0); }; return ( { if (!v) handleClose(); }}>
v{RELEASE_NOTES.version} · {RELEASE_NOTES.date}
What's new Release highlights for BillTracker v{RELEASE_NOTES.version}
{RELEASE_NOTES.highlights.map((item, i) => (

{item.title}

{item.desc}

))}
); }