forked from akai/readest
fix: make sidebar and notebook pin states persist after refresh (#2730)
This commit is contained in:
@@ -16,6 +16,7 @@ import { uniqueId } from '@/utils/misc';
|
||||
import { eventDispatcher } from '@/utils/event';
|
||||
import { getBookDirFromLanguage } from '@/utils/book';
|
||||
import { Overlay } from '@/components/Overlay';
|
||||
import { saveSysSettings } from '@/helpers/settings';
|
||||
import useShortcuts from '@/hooks/useShortcuts';
|
||||
import BooknoteItem from '../sidebar/BooknoteItem';
|
||||
import NotebookHeader from './Header';
|
||||
@@ -88,7 +89,9 @@ const Notebook: React.FC = ({}) => {
|
||||
|
||||
const handleTogglePin = () => {
|
||||
toggleNotebookPin();
|
||||
settings.globalReadSettings.isNotebookPinned = !isNotebookPinned;
|
||||
const globalReadSettings = settings.globalReadSettings;
|
||||
const newGlobalReadSettings = { ...globalReadSettings, isNotebookPinned: !isNotebookPinned };
|
||||
saveSysSettings(envConfig, 'globalReadSettings', newGlobalReadSettings);
|
||||
};
|
||||
|
||||
const handleClickOverlay = () => {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEnv } from '@/context/EnvContext';
|
||||
import { useSettingsStore } from '@/store/settingsStore';
|
||||
import { useSidebarStore } from '@/store/sidebarStore';
|
||||
import { useEffect } from 'react';
|
||||
import { saveSysSettings } from '@/helpers/settings';
|
||||
|
||||
const useSidebar = (initialWidth: string, isPinned: boolean) => {
|
||||
const { envConfig } = useEnv();
|
||||
const { settings } = useSettingsStore();
|
||||
const {
|
||||
sideBarWidth,
|
||||
@@ -30,8 +33,10 @@ const useSidebar = (initialWidth: string, isPinned: boolean) => {
|
||||
|
||||
const handleSideBarTogglePin = () => {
|
||||
toggleSideBarPin();
|
||||
settings.globalReadSettings.isSideBarPinned = !isSideBarPinned;
|
||||
if (isSideBarPinned && isSideBarVisible) setSideBarVisible(false);
|
||||
const globalReadSettings = settings.globalReadSettings;
|
||||
const newGlobalReadSettings = { ...globalReadSettings, isSideBarPinned: !isSideBarPinned };
|
||||
saveSysSettings(envConfig, 'globalReadSettings', newGlobalReadSettings);
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user