Correctly check if chapter exists

The wrong chapter list was used.
"chapters" is the filtered list of chapters, which e.g. doesn't contain duplicated chapters.
This caused the "chapter source order" to potentially be higher than the total chapters of the manga.

The end result of this was that the fetched state of the pages wasn't properly detected causing errors due to rendering the reader before it was in the correct state
This commit is contained in:
schroda
2025-01-04 15:55:48 +01:00
parent 62155005ab
commit afeb0f9aca

View File

@@ -83,7 +83,7 @@ const BaseReader = ({
setSettings, setSettings,
initialChapter, initialChapter,
currentChapter, currentChapter,
chapters, mangaChapters,
setReaderStateChapters, setReaderStateChapters,
firstPageUrl, firstPageUrl,
totalPages, totalPages,
@@ -105,7 +105,7 @@ const BaseReader = ({
'shouldSkipDupChapters' | 'backgroundColor' | 'shouldShowReadingModePreview' | 'shouldShowTapZoneLayoutPreview' 'shouldSkipDupChapters' | 'backgroundColor' | 'shouldShowReadingModePreview' | 'shouldShowTapZoneLayoutPreview'
> & > &
Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'tapZoneLayout' | 'tapZoneInvertMode'> & Pick<IReaderSettingsWithDefaultFlag, 'readingMode' | 'tapZoneLayout' | 'tapZoneInvertMode'> &
Pick<ReaderStateChapters, 'initialChapter' | 'currentChapter' | 'chapters' | 'setReaderStateChapters'> & Pick<ReaderStateChapters, 'initialChapter' | 'currentChapter' | 'mangaChapters' | 'setReaderStateChapters'> &
Pick< Pick<
ReaderStatePages, ReaderStatePages,
| 'totalPages' | 'totalPages'
@@ -164,7 +164,7 @@ const BaseReader = ({
!chaptersResponse.loading && !chaptersResponse.loading &&
!chaptersResponse.error && !chaptersResponse.error &&
chapterSourceOrder >= 0 && chapterSourceOrder >= 0 &&
chapterSourceOrder <= chapters.length; chapterSourceOrder <= mangaChapters.length;
const isLoading = const isLoading =
currentChapter === undefined || currentChapter === undefined ||
@@ -532,7 +532,7 @@ export const Reader = withPropsFrom(
'setSettings', 'setSettings',
'initialChapter', 'initialChapter',
'currentChapter', 'currentChapter',
'chapters', 'mangaChapters',
'setReaderStateChapters', 'setReaderStateChapters',
'firstPageUrl', 'firstPageUrl',
'totalPages', 'totalPages',