Simplify selecting zustand store state
This commit is contained in:
@@ -59,7 +59,7 @@ const BaseReaderNavBarDesktop = ({
|
||||
setReaderNavBarWidth,
|
||||
}: ReaderNavBarDesktopProps & Pick<NavbarContextType, 'setReaderNavBarWidth'>) => {
|
||||
const { t } = useLingui();
|
||||
const manga = useReaderStore((state) => state.manga);
|
||||
const manga = useReaderStore('manga');
|
||||
const {
|
||||
chapters,
|
||||
currentChapterId,
|
||||
@@ -77,7 +77,7 @@ const BaseReaderNavBarDesktop = ({
|
||||
previousChapter: state.previousChapter,
|
||||
nextChapter: state.nextChapter,
|
||||
}));
|
||||
const isStaticNav = useReaderSettingsStore((state) => state.isStaticNav);
|
||||
const isStaticNav = useReaderSettingsStore('isStaticNav');
|
||||
|
||||
const [navBarElement, setNavBarElement] = useState<HTMLDivElement | null>();
|
||||
useResizeObserver(
|
||||
|
||||
@@ -72,7 +72,7 @@ export const ReaderNavBarDesktopActions = memo(() => {
|
||||
}));
|
||||
|
||||
const { t } = useLingui();
|
||||
const pageLoadStates = useReaderPagesStore((state) => state.pageLoadStates);
|
||||
const pageLoadStates = useReaderPagesStore('pageLoadStates');
|
||||
|
||||
const pageRetryKeyPrefix = useRef<number>(0);
|
||||
|
||||
|
||||
@@ -23,10 +23,7 @@ import { ReaderControls } from '@/features/reader/services/ReaderControls.ts';
|
||||
const BaseReaderNavBarDesktopPageNavigation = () => {
|
||||
const { t } = useLingui();
|
||||
const getOptionForDirection = useGetOptionForDirection();
|
||||
const { currentPageIndex, pages } = useReaderPagesStore((state) => ({
|
||||
currentPageIndex: state.currentPageIndex,
|
||||
pages: state.pages,
|
||||
}));
|
||||
const { currentPageIndex, pages } = useReaderPagesStore('currentPageIndex', 'pages');
|
||||
const readingDirection = useReaderSettingsStore((state) => state.readingDirection.value);
|
||||
|
||||
const currentPage = useMemo(() => getPage(currentPageIndex, pages), [currentPageIndex, pages]);
|
||||
|
||||
@@ -23,14 +23,14 @@ import { useReaderSettingsStore } from '@/features/reader/stores/ReaderStore.ts'
|
||||
const BaseReaderNavBarDesktopQuickSettings = ({ openSettings }: Pick<ReaderNavBarDesktopProps, 'openSettings'>) => {
|
||||
const { t } = useLingui();
|
||||
const { readingMode, shouldOffsetDoubleSpreads, pageScaleMode, shouldStretchPage, readingDirection, autoScroll } =
|
||||
useReaderSettingsStore((state) => ({
|
||||
readingMode: state.readingMode,
|
||||
shouldOffsetDoubleSpreads: state.shouldOffsetDoubleSpreads,
|
||||
pageScaleMode: state.pageScaleMode,
|
||||
shouldStretchPage: state.shouldStretchPage,
|
||||
readingDirection: state.readingDirection,
|
||||
autoScroll: state.autoScroll,
|
||||
}));
|
||||
useReaderSettingsStore(
|
||||
'readingMode',
|
||||
'shouldOffsetDoubleSpreads',
|
||||
'pageScaleMode',
|
||||
'shouldStretchPage',
|
||||
'readingDirection',
|
||||
'autoScroll',
|
||||
);
|
||||
|
||||
return (
|
||||
<Stack sx={{ gap: 1 }}>
|
||||
|
||||
Reference in New Issue
Block a user