import { Box, Button, CssBaseline, LinearProgress, Typography } from "@mui/material"; import { appWindow } from "@tauri-apps/api/window"; import logo from "../../assets/icon.svg"; import { useEffect, useState } from "react"; import "./styles.css"; function useUpdateProgress() { const [progress, setProgress] = useState(null); useEffect(() => { const unlisten = appWindow.listen("app://update-progress", (event) => { setProgress(event.payload as number); }); return () => { unlisten.then((unlisten) => unlisten()); }; }, []); return progress; } export default function App() { const [error, setError] = useState(false); useEffect(() => { const unlisten = appWindow.listen("app://update-error", () => { setError(true); }); return () => { unlisten.then((unlisten) => unlisten()); }; }, []); const handleRetry = () => { setError(false); appWindow.emit("app://update"); }; return ( <> {error ? : } ); } function DownloadIndicator() { const progress = useUpdateProgress(); return ( <> Updating the GUI components... ); } function DownloadFailed({ onRetry }: { onRetry: () => void }) { return ( <> Failed to update the GUI components. ); } function LinearProgressWithLabel(props: { value: number | null }) { const { value } = props; return ( {value !== null && ( {`${Math.round(value)}%`} )} ); }