"use client"; import { useTranslation } from "react-i18next"; import { FaExternalLinkAlt, FaTimes } from "react-icons/fa"; import { LuCheckCheck } from "react-icons/lu"; import { Button } from "@/components/ui/button"; import type { AppUpdateInfo } from "@/types"; import { RippleButton } from "./ui/ripple"; interface AppUpdateToastProps { updateInfo: AppUpdateInfo; onRestart: () => Promise; onDismiss: () => void; updateReady?: boolean; } export function AppUpdateToast({ updateInfo, onRestart, onDismiss, updateReady = false, }: AppUpdateToastProps) { const { t } = useTranslation(); const handleRestartClick = async () => { await onRestart(); }; const handleViewRelease = () => { if (updateInfo.release_page_url) { const event = new CustomEvent("url-open-request", { detail: updateInfo.release_page_url, }); window.dispatchEvent(event); } }; return (
{updateReady ? t("appUpdate.toast.updateReady") : updateInfo.repo_update ? "Update available via package manager" : t("appUpdate.toast.manualDownloadRequired")}
{updateInfo.current_version} → {updateInfo.new_version}
{updateReady ? ( void handleRestartClick()} size="sm" className="flex items-center gap-2 text-xs" > {t("appUpdate.toast.restartNow")} ) : ( !updateInfo.repo_update && updateInfo.manual_update_required && ( {t("appUpdate.toast.viewRelease")} ) )} {t("appUpdate.toast.later")}
); }