mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-06-30 17:34:39 -05:00
fixed when spinner stops just after first offline chapter fetch
This commit is contained in:
@@ -44,10 +44,6 @@ const useStyles = makeStyles((theme: Theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// const InnerItem = React.memo(({ chapters, index }: any) => (
|
|
||||||
// <ChapterCard chapter={chapters[index]} />
|
|
||||||
// ));
|
|
||||||
|
|
||||||
export default function Manga() {
|
export default function Manga() {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -60,6 +56,7 @@ export default function Manga() {
|
|||||||
const [manga, setManga] = useState<IManga>();
|
const [manga, setManga] = useState<IManga>();
|
||||||
const [chapters, setChapters] = useState<IChapter[]>([]);
|
const [chapters, setChapters] = useState<IChapter[]>([]);
|
||||||
const [fetchedChapters, setFetchedChapters] = useState(false);
|
const [fetchedChapters, setFetchedChapters] = useState(false);
|
||||||
|
const [noChaptersFound, setNoChaptersFound] = useState(false);
|
||||||
const [chapterUpdateTriggerer, setChapterUpdateTriggerer] = useState(0);
|
const [chapterUpdateTriggerer, setChapterUpdateTriggerer] = useState(0);
|
||||||
|
|
||||||
function triggerChaptersUpdate() {
|
function triggerChaptersUpdate() {
|
||||||
@@ -84,20 +81,13 @@ export default function Manga() {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (data.length === 0 && fetchedChapters) {
|
if (data.length === 0 && fetchedChapters) {
|
||||||
makeToast('No chapters found', 'warning');
|
makeToast('No chapters found', 'warning');
|
||||||
|
setNoChaptersFound(true);
|
||||||
}
|
}
|
||||||
setChapters(data);
|
setChapters(data);
|
||||||
})
|
})
|
||||||
.then(() => setFetchedChapters(true));
|
.then(() => setFetchedChapters(true));
|
||||||
}, [chapters.length, fetchedChapters, chapterUpdateTriggerer]);
|
}, [chapters.length, fetchedChapters, chapterUpdateTriggerer]);
|
||||||
|
|
||||||
// const itemContent = (index:any) => <InnerItem chapters={chapters} index={index} />;
|
|
||||||
const itemContent = (index:any) => (
|
|
||||||
<ChapterCard
|
|
||||||
chapter={chapters[index]}
|
|
||||||
triggerChaptersUpdate={triggerChaptersUpdate}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<LoadingPlaceholder
|
<LoadingPlaceholder
|
||||||
@@ -107,7 +97,7 @@ export default function Manga() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<LoadingPlaceholder
|
<LoadingPlaceholder
|
||||||
shouldRender={chapters.length > 0 || fetchedChapters}
|
shouldRender={chapters.length > 0 || noChaptersFound}
|
||||||
>
|
>
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
style={{ // override Virtuoso default values and set them with class
|
style={{ // override Virtuoso default values and set them with class
|
||||||
@@ -115,7 +105,12 @@ export default function Manga() {
|
|||||||
}}
|
}}
|
||||||
className={classes.chapters}
|
className={classes.chapters}
|
||||||
totalCount={chapters.length}
|
totalCount={chapters.length}
|
||||||
itemContent={itemContent}
|
itemContent={(index:number) => (
|
||||||
|
<ChapterCard
|
||||||
|
chapter={chapters[index]}
|
||||||
|
triggerChaptersUpdate={triggerChaptersUpdate}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
useWindowScroll={window.innerWidth < 960}
|
useWindowScroll={window.innerWidth < 960}
|
||||||
overscan={window.innerHeight * 0.5}
|
overscan={window.innerHeight * 0.5}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user