import { useAppUpdater } from '@/hooks/useAppUpdater' import { IconDownload } from '@tabler/icons-react' import { Button } from '@/components/ui/button' import { useState, useEffect } from 'react' import { useReleaseNotes } from '@/hooks/useReleaseNotes' import { RenderMarkdown } from '../RenderMarkdown' import { cn, isDev } from '@/lib/utils' import { isNightly, isBeta } from '@/lib/version' const DialogAppUpdater = () => { const { updateState, downloadAndInstallUpdate, checkForUpdate, setRemindMeLater, } = useAppUpdater() const [showReleaseNotes, setShowReleaseNotes] = useState(false) const handleUpdate = () => { downloadAndInstallUpdate() setRemindMeLater(true) } const { release, fetchLatestRelease } = useReleaseNotes() useEffect(() => { if (!isDev()) { fetchLatestRelease(isBeta) } }, [fetchLatestRelease]) // Check for updates when component mounts useEffect(() => { checkForUpdate() }, [checkForUpdate]) const [appUpdateState, setAppUpdateState] = useState({ remindMeLater: false, isUpdateAvailable: false, }) useEffect(() => { setAppUpdateState({ remindMeLater: updateState.remindMeLater, isUpdateAvailable: updateState.isUpdateAvailable, }) }, [updateState]) if (appUpdateState.remindMeLater) return null return ( <> {appUpdateState.isUpdateAvailable && (
You are using a nightly build. This version is built from the latest development branch and may not have release notes.
) : (