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

@@ -52,6 +52,10 @@ const Search: React.FC = () => {
[] as (MovieResult | TvResult | PersonResult)[]
);
const isEmpty = !isLoadingInitialData && titles?.length === 0;
const isReachingEnd =
isEmpty || (data && data[data.length - 1]?.results.length < 20);
return (
<>
<div className="md:flex md:items-center md:justify-between mb-8 mt-6">
@@ -79,10 +83,11 @@ const Search: React.FC = () => {
</div>
<ListView
items={titles}
isEmpty={!isLoadingInitialData && titles?.length === 0}
isEmpty={isEmpty}
isLoading={
isLoadingInitialData || (isLoadingMore && (titles?.length ?? 0) > 0)
}
isReachingEnd={isReachingEnd}
onScrollBottom={fetchMore}
/>
</>