mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2025-01-25 23:11:17 +01:00
prevPage handle
* go back to previous chapter on page 0 when prevPage is triggered
This commit is contained in:
parent
c49fc0ff5f
commit
e97642d92a
@ -22,7 +22,7 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
export default function PagedReader(props: IReaderProps) {
|
export default function PagedReader(props: IReaderProps) {
|
||||||
const {
|
const {
|
||||||
pages, settings, setCurPage, curPage, nextChapter,
|
pages, settings, setCurPage, curPage, nextChapter, prevChapter,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@ -38,7 +38,7 @@ export default function PagedReader(props: IReaderProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prevPage() {
|
function prevPage() {
|
||||||
if (curPage > 0) { setCurPage(curPage - 1); }
|
if (curPage > 0) { setCurPage(curPage - 1); } else if (curPage === 0) { prevChapter(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
function keyboardControl(e:KeyboardEvent) {
|
function keyboardControl(e:KeyboardEvent) {
|
||||||
|
@ -21,7 +21,7 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
export default function VerticalReader(props: IReaderProps) {
|
export default function VerticalReader(props: IReaderProps) {
|
||||||
const {
|
const {
|
||||||
pages, settings, setCurPage, curPage, chapter, nextChapter,
|
pages, settings, setCurPage, curPage, chapter, nextChapter, prevChapter,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@ -47,6 +47,8 @@ export default function VerticalReader(props: IReaderProps) {
|
|||||||
pagesRef.current[curPage - 1]?.scrollIntoView();
|
pagesRef.current[curPage - 1]?.scrollIntoView();
|
||||||
setCurPage(curPage - 1);
|
setCurPage(curPage - 1);
|
||||||
}
|
}
|
||||||
|
} else if (curPage === 0) {
|
||||||
|
prevChapter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +139,7 @@ export default function Reader() {
|
|||||||
}
|
}
|
||||||
}, [curPage]);
|
}, [curPage]);
|
||||||
|
|
||||||
|
// return spinner while chpater data is loading
|
||||||
if (chapter.pageCount === -1) {
|
if (chapter.pageCount === -1) {
|
||||||
return (
|
return (
|
||||||
<div className={classes.loading}>
|
<div className={classes.loading}>
|
||||||
@ -158,6 +159,12 @@ export default function Reader() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const prevChapter = () => {
|
||||||
|
if (chapter.index > 1) {
|
||||||
|
history.push(`/manga/${manga.id}/chapter/${chapter.index - 1}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const pages = range(chapter.pageCount).map((index) => ({
|
const pages = range(chapter.pageCount).map((index) => ({
|
||||||
index,
|
index,
|
||||||
src: `${serverAddress}/api/v1/manga/${mangaId}/chapter/${chapterIndex}/page/${index}`,
|
src: `${serverAddress}/api/v1/manga/${mangaId}/chapter/${chapterIndex}/page/${index}`,
|
||||||
@ -181,6 +188,7 @@ export default function Reader() {
|
|||||||
manga={manga}
|
manga={manga}
|
||||||
chapter={chapter}
|
chapter={chapter}
|
||||||
nextChapter={nextChapter}
|
nextChapter={nextChapter}
|
||||||
|
prevChapter={prevChapter}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
1
webUI/react/src/typings.d.ts
vendored
1
webUI/react/src/typings.d.ts
vendored
@ -117,4 +117,5 @@ interface IReaderProps {
|
|||||||
manga: IMangaCard | IManga
|
manga: IMangaCard | IManga
|
||||||
chapter: IChapter | IPartialChpter
|
chapter: IChapter | IPartialChpter
|
||||||
nextChapter: () => void
|
nextChapter: () => void
|
||||||
|
prevChapter: () => void
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user