diff --git a/tranga-website/src/Components/MangaPopup.tsx b/tranga-website/src/Components/MangaPopup.tsx index cdc962e..8a76e6f 100644 --- a/tranga-website/src/Components/MangaPopup.tsx +++ b/tranga-website/src/Components/MangaPopup.tsx @@ -1,7 +1,12 @@ import IManga from "../api/types/IManga.ts"; import {Badge, Box, Chip, CircularProgress, Drawer, Input, Link, Skeleton, Stack, Typography} from "@mui/joy"; import {ReactElement, useCallback, useContext, useEffect, useRef, useState} from "react"; -import {GetLatestChapterAvailable, GetMangaCoverImageUrl, SetIgnoreThreshold} from "../api/Manga.tsx"; +import { + GetLatestChapterAvailable, + GetLatestChapterDownloaded, + GetMangaCoverImageUrl, + SetIgnoreThreshold +} from "../api/Manga.tsx"; import {ApiUriContext, getData} from "../api/fetchApi.tsx"; import MarkdownPreview from "@uiw/react-markdown-preview"; import {CardHeight} from "./Manga.tsx"; @@ -33,6 +38,7 @@ export default function MangaPopup({manga, open, children} : {manga: IManga | nu if(!open) return; LoadMaxChapter(); + LoadDownloadedChapter(); LoadMangaCover(); }, [open]); @@ -47,6 +53,17 @@ export default function MangaPopup({manga, open, children} : {manga: IManga | nu .finally(() => setMaxChapterLoading(false)); }, [manga, apiUri]); + const [mangaDownloadedChapter, setMangaDownloadedChapter] = useState(); + const [downloadedChapterLoading, setDownloadedChapterLoading] = useState(true); + const LoadDownloadedChapter = useCallback(() => { + if(manga == null) + return; + setDownloadedChapterLoading(true); + GetLatestChapterDownloaded(apiUri, manga.mangaId) + .then(setMangaDownloadedChapter) + .finally(() => setDownloadedChapterLoading(false)); + }, [manga, apiUri]); + const [updatingThreshold, setUpdatingThreshold] = useState(false); const updateIgnoreThreshhold = useCallback((value: number) => { if(manga == null) @@ -88,7 +105,7 @@ export default function MangaPopup({manga, open, children} : {manga: IManga | nu {