From e9d66e65ad01f51488665fedf0e5db341d471d2b Mon Sep 17 00:00:00 2001 From: Nayam Amarshe <25067102+NayamAmarshe@users.noreply.github.com> Date: Sat, 24 Dec 2022 14:15:15 +0530 Subject: [PATCH] Added model default value --- renderer/components/LeftPaneImageSteps.tsx | 18 +++++++++++++++++- renderer/pages/index.tsx | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/renderer/components/LeftPaneImageSteps.tsx b/renderer/components/LeftPaneImageSteps.tsx index c74daa5..15b1197 100644 --- a/renderer/components/LeftPaneImageSteps.tsx +++ b/renderer/components/LeftPaneImageSteps.tsx @@ -53,13 +53,29 @@ function LeftPaneImageSteps({ setSaveImageAs, dimensions, }: IProps) { + const [currentModel, setCurrentModel] = useState<{ + label: string; + value: string; + }>({ + label: null, + value: null, + }); + useEffect(() => { themeChange(false); + if (!localStorage.getItem("saveImageAs")) { localStorage.setItem("saveImageAs", "png"); } else { setSaveImageAs(localStorage.getItem("saveImageAs")); } + + if (!localStorage.getItem("model")) { + setCurrentModel(modelOptions[0]); + localStorage.setItem("model", JSON.stringify(modelOptions[0])); + } else { + setCurrentModel(JSON.parse(localStorage.getItem("model"))); + } }, []); const setExportType = (format: string) => { @@ -176,7 +192,7 @@ function LeftPaneImageSteps({ onChange={handleModelChange} className="react-select-container" classNamePrefix="react-select" - defaultValue={modelOptions[0]} + value={currentModel} /> {model !== "models-DF2K" && !batchMode && ( diff --git a/renderer/pages/index.tsx b/renderer/pages/index.tsx index 7dc1da8..1020842 100644 --- a/renderer/pages/index.tsx +++ b/renderer/pages/index.tsx @@ -240,6 +240,10 @@ const Home = () => { const handleModelChange = (e) => { setModel(e.value); + localStorage.setItem( + "model", + JSON.stringify({ label: e.label, value: e.value }) + ); if (e.value === "models-DF2K") { setDoubleUpscayl(false); }