import React, { useEffect } from "react"; import UpscaylSVGLogo from "@/components/icons/upscayl-logo-svg"; import { useAtomValue } from "jotai"; import { translationAtom } from "@/atoms/translations-atom"; import { ELECTRON_COMMANDS } from "@common/electron-commands"; import useLogger from "../hooks/use-logger"; function ProgressBar({ progress, doubleUpscaylCounter, batchMode, resetImagePaths, }: { progress: string; doubleUpscaylCounter: number; batchMode: boolean; resetImagePaths: () => void; }) { const [batchProgress, setBatchProgress] = React.useState(0); const t = useAtomValue(translationAtom); const logit = useLogger(); useEffect(() => { const progressString = progress.trim().replace(/\n/g, ""); // Remove trailing and leading spaces if (progressString.includes("Successful")) { setBatchProgress((prev) => prev + 1); } }, [progress]); const stopHandler = () => { window.electron.send(ELECTRON_COMMANDS.STOP); logit("🛑 Stopping Upscayl"); resetImagePaths(); }; // const progressStyle = useMemo(() => { // if (progress.includes("%")) { // return { // "--value": parseFloat(progress.replace("%", "")), // }; // } else if (progress.includes("Success")) { // return { // "--value": 100, // }; // } // return { // "--value": 0, // }; // }, [progress]); return (
{batchMode && `${t("APP.PROGRESS_BAR.BATCH_UPSCAYL_IN_PROGRESS_TITLE")} ${batchProgress}`}
{progress} {!batchMode && doubleUpscaylCounter > 0 && "\nPass " + doubleUpscaylCounter}
) : ({progress}
)}{t("APP.PROGRESS_BAR.IN_PROGRESS_TITLE")}