import { AlertCircle, Download, RefreshCw } from 'lucide-react'; import { useEffect, useState } from 'react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Progress } from '@/components/ui/progress'; import { useAutoUpdater } from '@/hooks/useAutoUpdater'; import { usePlatform } from '@/platform/PlatformContext'; export function UpdateStatus() { const platform = usePlatform(); const { status, checkForUpdates, downloadAndInstall, restartAndInstall } = useAutoUpdater(false); const [currentVersion, setCurrentVersion] = useState(''); const isDev = !import.meta.env?.PROD; useEffect(() => { platform.metadata .getVersion() .then(setCurrentVersion) .catch(() => setCurrentVersion('Unknown')); }, [platform]); return ( App Updates
Current Version
v{currentVersion} {isDev ? ' (dev)' : ''}
{!isDev && ( )}
{isDev ? (
Auto-updates are disabled in development mode.
) : ( <> {status.checking && (
Checking for updates...
)} {status.error && (
{status.error}
)} {status.available && !status.downloading && !status.readyToInstall && (
Update Available
Version {status.version}
New
)} {status.downloading && (
Downloading update...
{status.downloadProgress !== undefined && ( {status.downloadProgress}% )}
{status.downloadedBytes !== undefined && status.totalBytes !== undefined && status.totalBytes > 0 && (
{(status.downloadedBytes / 1024 / 1024).toFixed(1)} MB /{' '} {(status.totalBytes / 1024 / 1024).toFixed(1)} MB
)}
)} {status.readyToInstall && (
Update Ready to Install
Version {status.version} has been downloaded
The app needs to restart to complete the installation. You can do this now or later at your convenience.
)} {!status.available && !status.checking && !status.error && (
You're up to date
)} )}
); }