fix(frontend): when there were no results in the list view, it would call fetch more infinitely
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user