interface: fix simultaneous requests in loading

This commit is contained in:
Liam Fitzgerald 2021-06-30 13:24:23 +10:00
parent b1b9bc01e8
commit 0a29d95cb8
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB

View File

@ -36,10 +36,10 @@ export function useLazyScroll(
}; };
useEffect(() => { useEffect(() => {
if((oldCount > count) && ref.current) { if((oldCount > count) && ref.current && !isLoading) {
loadUntil(ref.current); loadUntil(ref.current);
} }
}, [count]); }, [count, isLoading]);
useEffect(() => { useEffect(() => {
if(!ready) { if(!ready) {
@ -48,7 +48,7 @@ export function useLazyScroll(
}, [ready]); }, [ready]);
useEffect(() => { useEffect(() => {
if (!ref.current || isDone || !ready) { if (!ref.current || isDone || !ready || isLoading) {
return; return;
} }
const scroll = ref.current; const scroll = ref.current;
@ -64,7 +64,7 @@ export function useLazyScroll(
return () => { return () => {
ref.current?.removeEventListener('scroll', onScroll); ref.current?.removeEventListener('scroll', onScroll);
}; };
}, [ref?.current, ready, isDone]); }, [ref?.current, ready, isDone, isLoading]);
return { isDone, isLoading }; return { isDone, isLoading };
} }