From 1c80cb2cd54f9f3781dd4815ea0445f3dfa79474 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Thu, 5 Dec 2024 19:00:50 +0800 Subject: [PATCH] enhancement: default open Jan Input Box Settings and Right panel (#4234) * enhancement: default open Jan Input Box Settings and Right panel * chore: added option getOnInit atomstorage --- web/containers/Providers/Responsive.tsx | 5 ++--- web/helpers/atoms/App.atom.ts | 13 ++++++++++++- web/helpers/atoms/Thread.atom.ts | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/containers/Providers/Responsive.tsx b/web/containers/Providers/Responsive.tsx index cb7bd4c1c..f73fdc970 100644 --- a/web/containers/Providers/Responsive.tsx +++ b/web/containers/Providers/Responsive.tsx @@ -11,15 +11,14 @@ const Responsive = () => { const [showRightPanel, setShowRightPanel] = useAtom(showRightPanelAtom) // Refs to store the last known state of the panels - const lastLeftPanelState = useRef(true) - const lastRightPanelState = useRef(true) + const lastLeftPanelState = useRef(showLeftPanel) + const lastRightPanelState = useRef(showRightPanel) useEffect(() => { if (matches) { // Store the last known state before closing the panels lastLeftPanelState.current = showLeftPanel lastRightPanelState.current = showRightPanel - setShowLeftPanel(false) setShowRightPanel(false) } else { diff --git a/web/helpers/atoms/App.atom.ts b/web/helpers/atoms/App.atom.ts index 8770b4bcd..bd1e4f7aa 100644 --- a/web/helpers/atoms/App.atom.ts +++ b/web/helpers/atoms/App.atom.ts @@ -1,14 +1,25 @@ import { atom } from 'jotai' +import { atomWithStorage } from 'jotai/utils' + import { MainViewState } from '@/constants/screens' export const mainViewStateAtom = atom(MainViewState.Thread) export const defaultJanDataFolderAtom = atom('') +const SHOW_RIGHT_PANEL = 'showRightPanel' + // Store panel atom export const showLeftPanelAtom = atom(true) -export const showRightPanelAtom = atom(true) + +export const showRightPanelAtom = atomWithStorage( + SHOW_RIGHT_PANEL, + false, + undefined, + { getOnInit: true } +) + export const showSystemMonitorPanelAtom = atom(false) export const appDownloadProgressAtom = atom(-1) export const updateVersionErrorAtom = atom(undefined) diff --git a/web/helpers/atoms/Thread.atom.ts b/web/helpers/atoms/Thread.atom.ts index e0ea433ce..7fb6f3c60 100644 --- a/web/helpers/atoms/Thread.atom.ts +++ b/web/helpers/atoms/Thread.atom.ts @@ -207,7 +207,7 @@ export const setThreadModelParamsAtom = atom( */ export const activeSettingInputBoxAtom = atomWithStorage( ACTIVE_SETTING_INPUT_BOX, - false, + true, undefined, { getOnInit: true } )