Use proper name for reader url chapter "index" param
It's not the index of the chapter but the source order, which is starting at 1 and not 0
This commit is contained in:
@@ -150,8 +150,8 @@ export const AppRoutes = {
|
|||||||
path: '/tracker/login/oauth',
|
path: '/tracker/login/oauth',
|
||||||
},
|
},
|
||||||
reader: {
|
reader: {
|
||||||
match: '/manga/:mangaId/chapter/:chapterIndex/*',
|
match: '/manga/:mangaId/chapter/:chapterSourceOrder/*',
|
||||||
path: (mangaId: MangaIdInfo['id'], chapterIndex: ChapterSourceOrderInfo['sourceOrder']) =>
|
path: (mangaId: MangaIdInfo['id'], chapterSourceOrder: ChapterSourceOrderInfo['sourceOrder']) =>
|
||||||
`/manga/${mangaId}/chapter/${chapterIndex}`,
|
`/manga/${mangaId}/chapter/${chapterSourceOrder}`,
|
||||||
},
|
},
|
||||||
} satisfies TAppRoutes;
|
} satisfies TAppRoutes;
|
||||||
|
|||||||
@@ -129,11 +129,11 @@ const BaseReader = ({
|
|||||||
|
|
||||||
const [areSettingsSet, setAreSettingsSet] = useState(false);
|
const [areSettingsSet, setAreSettingsSet] = useState(false);
|
||||||
|
|
||||||
const { chapterIndex: paramChapterIndex, mangaId: paramMangaId } = useParams<{
|
const { chapterSourceOrder: paramChapterSourceOrder, mangaId: paramMangaId } = useParams<{
|
||||||
chapterIndex: string;
|
chapterSourceOrder: string;
|
||||||
mangaId: string;
|
mangaId: string;
|
||||||
}>();
|
}>();
|
||||||
const chapterIndex = Number(paramChapterIndex);
|
const chapterSourceOrder = Number(paramChapterSourceOrder);
|
||||||
const mangaId = Number(paramMangaId);
|
const mangaId = Number(paramMangaId);
|
||||||
|
|
||||||
const mangaResponse = requestManager.useGetManga<GetMangaReaderQuery>(GET_MANGA_READER, mangaId);
|
const mangaResponse = requestManager.useGetManga<GetMangaReaderQuery>(GET_MANGA_READER, mangaId);
|
||||||
@@ -162,8 +162,8 @@ const BaseReader = ({
|
|||||||
const doesChapterExist =
|
const doesChapterExist =
|
||||||
!chaptersResponse.loading &&
|
!chaptersResponse.loading &&
|
||||||
!chaptersResponse.error &&
|
!chaptersResponse.error &&
|
||||||
chapterIndex >= 0 &&
|
chapterSourceOrder >= 0 &&
|
||||||
chapterIndex <= chapters.length - 1;
|
chapterSourceOrder <= chapters.length - 1;
|
||||||
|
|
||||||
const isLoading =
|
const isLoading =
|
||||||
!areSettingsSet ||
|
!areSettingsSet ||
|
||||||
@@ -176,12 +176,12 @@ const BaseReader = ({
|
|||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!manga || !currentChapter) {
|
if (!manga || !currentChapter) {
|
||||||
setTitle(t('reader.title', { mangaId, chapterIndex }));
|
setTitle(t('reader.title', { mangaId, chapterIndex: chapterSourceOrder }));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(`${manga.title}: ${currentChapter.name}`);
|
setTitle(`${manga.title}: ${currentChapter.name}`);
|
||||||
}, [t, mangaId, chapterIndex, manga, currentChapter]);
|
}, [t, mangaId, chapterSourceOrder, manga, currentChapter]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
doFetchPages();
|
doFetchPages();
|
||||||
@@ -333,7 +333,7 @@ const BaseReader = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newMangaChapters = chaptersResponse.data?.chapters.nodes;
|
const newMangaChapters = chaptersResponse.data?.chapters.nodes;
|
||||||
const newCurrentChapter = newMangaChapters
|
const newCurrentChapter = newMangaChapters
|
||||||
? (newMangaChapters[newMangaChapters.length - chapterIndex] ?? null)
|
? (newMangaChapters[newMangaChapters.length - chapterSourceOrder] ?? null)
|
||||||
: undefined;
|
: undefined;
|
||||||
const newInitialChapter = initialChapter ?? newCurrentChapter;
|
const newInitialChapter = initialChapter ?? newCurrentChapter;
|
||||||
|
|
||||||
@@ -362,7 +362,7 @@ const BaseReader = ({
|
|||||||
skipDupeChapter: newInitialChapter,
|
skipDupeChapter: newInitialChapter,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}, [chaptersResponse.data?.chapters.nodes, chapterIndex, shouldSkipDupChapters]);
|
}, [chaptersResponse.data?.chapters.nodes, chapterSourceOrder, shouldSkipDupChapters]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
setOverride({
|
setOverride({
|
||||||
|
|||||||
Reference in New Issue
Block a user