import { motion } from "framer-motion"; import { useEffect, useRef, useState } from "react"; import { BsManagerIcon } from "../components/nav-bar/bsmanager-icon.component"; import { BsmProgressBar } from "../components/progress-bar/bsm-progress-bar.component"; import TitleBar from "../components/title-bar/title-bar.component"; import { useTranslation } from "../hooks/use-translation.hook"; import { AutoUpdaterService } from "../services/auto-updater.service"; import { WindowManagerService } from "../services/window-manager.service"; import { useService } from "renderer/hooks/use-service.hook"; import { lastValueFrom } from "rxjs"; import { logRenderError } from "renderer"; export default function Launcher() { const updaterService = useService(AutoUpdaterService); const windowService = useService(WindowManagerService); const constraintsRef = useRef(null); const [text, setText] = useState("auto-update.checking"); const t = useTranslation(); useEffect(() => { updaterService.isUpdateAvailable().then(available => { if (!available) { return windowService.openThenCloseAll("index.html"); } setText("auto-update.downloading"); return lastValueFrom(updaterService.downloadUpdate()) .then(() => updaterService.quitAndInstall()) .catch((err) => {logRenderError("omg", err); windowService.openThenCloseAll("index.html")}); }).catch(() => windowService.openThenCloseAll("index.html")); }, []); return (
{t(text)}
); }