handle manga page numbers

This commit is contained in:
Aria Moradi
2021-01-19 15:07:20 +03:30
parent fade116a02
commit 32a9321b8a
5 changed files with 17 additions and 14 deletions

View File

@@ -11,10 +11,11 @@ export default function MangaList(props: { popular: boolean }) {
const { sourceId } = useParams<{sourceId: string}>();
let mapped;
const [mangas, setMangas] = useState<IManga[]>([]);
const [lastPageNum] = useState<number>(1);
useEffect(() => {
const sourceType = props.popular ? 'popular' : 'latest';
fetch(`http://127.0.0.1:4567/api/v1/source/${sourceId}/${sourceType}`)
fetch(`http://127.0.0.1:4567/api/v1/source/${sourceId}/${sourceType}/${lastPageNum}`)
.then((response) => response.json())
.then((data: { title: string, thumbnail_url: string }[]) => setMangas(
data.map((it) => ({ title: it.title, thumbnailUrl: it.thumbnail_url })),