fix(frontend): when there were no results in the list view, it would call fetch more infinitely

This commit is contained in:
sct
2020-11-12 08:31:29 +00:00
parent 366074c12a
commit c0ce87b6f6
8 changed files with 46 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ interface ListViewProps {
items?: (TvResult | MovieResult | PersonResult)[];
isEmpty?: boolean;
isLoading?: boolean;
isReachingEnd?: boolean;
onScrollBottom: () => void;
}
@@ -20,8 +21,9 @@ const ListView: React.FC<ListViewProps> = ({
isEmpty,
isLoading,
onScrollBottom,
isReachingEnd,
}) => {
useVerticalScroll(onScrollBottom, !isLoading);
useVerticalScroll(onScrollBottom, !isLoading && !isEmpty && !isReachingEnd);
return (
<>
{isEmpty && (
@@ -79,6 +81,7 @@ const ListView: React.FC<ListViewProps> = ({
);
})}
{isLoading &&
!isReachingEnd &&
[...Array(10)].map((_item, i) => (
<li
key={`placeholder-${i}`}