import { useAtom, useAtomValue } from "jotai"; import React, { useEffect, useState } from "react"; import Select from "react-select"; import ReactTooltip from "react-tooltip"; import { themeChange } from "theme-change"; import { modelsListAtom } from "../atoms/modelsListAtom"; import useLog from "./hooks/useLog"; interface IProps { progress: string; selectImageHandler: () => Promise; selectFolderHandler: () => Promise; handleModelChange: (e: any) => void; outputHandler: () => Promise; upscaylHandler: () => Promise; batchMode: boolean; setBatchMode: React.Dispatch>; imagePath: string; outputPath: string; doubleUpscayl: boolean; setDoubleUpscayl: React.Dispatch>; dimensions: { width: number | null; height: number | null; }; setSaveImageAs: React.Dispatch>; setModel: React.Dispatch>; setGpuId: React.Dispatch>; } function LeftPaneImageSteps({ progress, selectImageHandler, selectFolderHandler, handleModelChange, outputHandler, upscaylHandler, batchMode, setBatchMode, imagePath, outputPath, doubleUpscayl, setDoubleUpscayl, dimensions, setSaveImageAs, setModel, setGpuId, }: IProps) { const [currentModel, setCurrentModel] = useState<{ label: string; value: string; }>({ label: null, value: null, }); const modelOptions = useAtomValue(modelsListAtom); const { logit } = useLog(); useEffect(() => { themeChange(false); if (!localStorage.getItem("saveImageAs")) { logit("📢 Setting saveImageAs to png"); localStorage.setItem("saveImageAs", "png"); } else { const currentlySavedImageFormat = localStorage.getItem("saveImageAs"); logit( "📢 Getting saveImageAs from localStorage", currentlySavedImageFormat ); setSaveImageAs(currentlySavedImageFormat); } if (!localStorage.getItem("model")) { setCurrentModel(modelOptions[0]); setModel(modelOptions[0].value); localStorage.setItem("model", JSON.stringify(modelOptions[0])); logit("📢 Setting model to", modelOptions[0].value); } else { const currentlySavedModel = JSON.parse( localStorage.getItem("model") ) as (typeof modelOptions)[0]; setCurrentModel(currentlySavedModel); setModel(currentlySavedModel.value); logit( "📢 Getting model from localStorage", JSON.stringify(currentlySavedModel) ); } if (!localStorage.getItem("gpuId")) { localStorage.setItem("gpuId", ""); logit("📢 Setting gpuId to empty string"); } else { const currentlySavedGpuId = localStorage.getItem("gpuId"); setGpuId(currentlySavedGpuId); logit("📢 Getting gpuId from localStorage", currentlySavedGpuId); } }, []); useEffect(() => { logit("📢 Setting model to", currentModel.value); }, [currentModel]); return (
{/* BATCH OPTION */}
setBatchMode((oldValue) => !oldValue)}>

Batch Upscale

{/* STEP 1 */}

Step 1

{/* STEP 2 */}

Step 2

Select Upscaling Type

{ if (e.target.checked) { setDoubleUpscayl(true); } else { setDoubleUpscayl(false); } }} />

{ setDoubleUpscayl(!doubleUpscayl); }}> Double Upscayl

)}
{/* STEP 3 */}

Step 3

Defaults to {!batchMode ? "Image's" : "Folder's"} path

{/* STEP 4 */}

Step 4

{dimensions.width && dimensions.height && (

Upscale from{" "} {dimensions.width}x{dimensions.height} {" "} to{" "} {doubleUpscayl ? dimensions.width * 16 : dimensions.width * 4}x {doubleUpscayl ? dimensions.height * 16 : dimensions.height * 4}

)}
); } export default LeftPaneImageSteps;