From 875c28488d4c4e74ab5e12c1dcf17e0990f38468 Mon Sep 17 00:00:00 2001 From: Feenix <25067102+NayamAmarshe@users.noreply.github.com> Date: Mon, 1 May 2023 14:53:11 +0530 Subject: [PATCH] Fixed empty select --- renderer/components/LeftPaneImageSteps.tsx | 54 ++++++++++++++++++++++ renderer/components/SettingsTab.tsx | 11 ++--- renderer/pages/index.tsx | 3 ++ 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/renderer/components/LeftPaneImageSteps.tsx b/renderer/components/LeftPaneImageSteps.tsx index 3d574c0..9a70472 100644 --- a/renderer/components/LeftPaneImageSteps.tsx +++ b/renderer/components/LeftPaneImageSteps.tsx @@ -23,6 +23,9 @@ interface IProps { width: number | null; height: number | null; }; + setSaveImageAs: React.Dispatch>; + setModel: React.Dispatch>; + setGpuId: React.Dispatch>; } function LeftPaneImageSteps({ @@ -39,6 +42,9 @@ function LeftPaneImageSteps({ doubleUpscayl, setDoubleUpscayl, dimensions, + setSaveImageAs, + setModel, + setGpuId, }: IProps) { const [currentModel, setCurrentModel] = useState<{ label: string; @@ -50,6 +56,54 @@ function LeftPaneImageSteps({ 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 */} diff --git a/renderer/components/SettingsTab.tsx b/renderer/components/SettingsTab.tsx index 2f7c0e4..3df5c4a 100644 --- a/renderer/components/SettingsTab.tsx +++ b/renderer/components/SettingsTab.tsx @@ -68,7 +68,10 @@ function SettingsTab({ ) as (typeof modelOptions)[0]; setCurrentModel(currentlySavedModel); setModel(currentlySavedModel.value); - logit("📢 Getting model from localStorage", currentlySavedModel.value); + logit( + "📢 Getting model from localStorage", + JSON.stringify(currentlySavedModel) + ); } if (!localStorage.getItem("gpuId")) { @@ -97,10 +100,6 @@ function SettingsTab({ } }, []); - useEffect(() => { - logit("📢 Setting model to", currentModel.value); - }, [currentModel]); - // HANDLERS const setExportType = (format: string) => { setSaveImageAs(format); @@ -203,7 +202,7 @@ function SettingsTab({ />
- {/* GPU ID INPUT */} + {/* CUSTOM MODEL */}

ADD CUSTOM MODELS

{customModelsPath}

diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index 00cc9fc..c5ed1e3 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -554,6 +554,9 @@ const Home = () => { doubleUpscayl={doubleUpscayl} setDoubleUpscayl={setDoubleUpscayl} dimensions={dimensions} + setGpuId={setGpuId} + setModel={setModel} + setSaveImageAs={setSaveImageAs} /> )}