import { useEffect, useState } from "react"; import { AlertCircle, Download, Package } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Spinner } from "@/components/ui/spinner"; import { toastWithSound as toast } from "@/lib/toast-with-sound"; import { DownloadExtractor, IsExtractorInstalled } from "../../wailsjs/go/main/App"; interface DependencySetupDialogProps { onInstalled?: () => void; } export function DependencySetupDialog({ onInstalled }: DependencySetupDialogProps) { const [open, setOpen] = useState(false); const [checking, setChecking] = useState(true); const [downloading, setDownloading] = useState(false); const [errorMessage, setErrorMessage] = useState(null); useEffect(() => { let cancelled = false; const checkDependency = async () => { try { const installed = await IsExtractorInstalled(); if (!cancelled) { setOpen(!installed); setErrorMessage(null); } } catch { if (!cancelled) { setOpen(true); setErrorMessage("Couldn't verify the core dependency. You can install it now."); } } finally { if (!cancelled) { setChecking(false); } } }; checkDependency(); return () => { cancelled = true; }; }, []); const handleDownload = async () => { setDownloading(true); setErrorMessage(null); try { await DownloadExtractor(); setOpen(false); toast.success("Core dependency installed"); onInstalled?.(); } catch (error) { const message = error instanceof Error ? error.message : String(error); setErrorMessage(message || "Failed to download dependency."); toast.error("Failed to download dependency"); } finally { setDownloading(false); } }; if (checking && !open) { return null; } return ( !downloading && setOpen(nextOpen)}>
Download Core Dependency This app now uses a prebuilt xtractor binary from GitHub releases. Download it once so fetching can work on this device.
The binary is stored in the app data folder and reused on the next launch. Optional tools like FFmpeg and ExifTool stay available in Settings.
{errorMessage && (

{errorMessage}

)}
); }