Simplify ReaderControls#useOpenChapter

This commit is contained in:
schroda
2025-09-20 19:51:26 +02:00
parent 1c0b982bae
commit f5c7379fc4
6 changed files with 187 additions and 229 deletions

View File

@@ -31,10 +31,8 @@ const BaseReaderNavBarDesktopChapterNavigation = ({
nextChapter,
chapters = [],
readerThemeDirection,
openChapter,
}: Pick<ReaderStateChapters, 'chapters' | 'currentChapter' | 'previousChapter' | 'nextChapter'> & {
readerThemeDirection: ReturnType<typeof ReaderService.useGetThemeDirection>;
openChapter: ReturnType<typeof ReaderControls.useOpenChapter>;
}) => {
const { t } = useTranslation();
@@ -56,7 +54,7 @@ const BaseReaderNavBarDesktopChapterNavigation = ({
),
)}
onClick={() => {
openChapter(getOptionForDirection('previous', 'next', readerThemeDirection));
ReaderControls.openChapter(getOptionForDirection('previous', 'next', readerThemeDirection));
}}
disabled={getOptionForDirection(!previousChapter, !nextChapter, readerThemeDirection)}
/>
@@ -88,7 +86,7 @@ const BaseReaderNavBarDesktopChapterNavigation = ({
),
)}
onClick={() => {
openChapter(getOptionForDirection('next', 'previous', readerThemeDirection));
ReaderControls.openChapter(getOptionForDirection('next', 'previous', readerThemeDirection));
}}
disabled={getOptionForDirection(!nextChapter, !previousChapter, readerThemeDirection)}
/>
@@ -122,9 +120,6 @@ export const ReaderNavBarDesktopChapterNavigation = withPropsFrom(
() => ({
readerThemeDirection: ReaderService.useGetThemeDirection(),
}),
() => ({
openChapter: ReaderControls.useOpenChapter(),
}),
],
['readerThemeDirection', 'openChapter'],
['readerThemeDirection'],
);