Fix infinite scroll
This commit is contained in:
parent
1957de483c
commit
6e436c7ee4
6
src/cache/index.ts
vendored
6
src/cache/index.ts
vendored
@ -26,9 +26,9 @@ const getPhotosCacheTags = (options: GetPhotosOptions = {}) => {
|
|||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
if (sortBy !== undefined) { tags.push(`sortBy-${sortBy}`); }
|
if (sortBy !== undefined) { tags.push(`sortBy-${sortBy}`); }
|
||||||
if (limit !== undefined) { tags.push(`limit-${sortBy}`); }
|
if (limit !== undefined) { tags.push(`limit-${limit}`); }
|
||||||
if (offset !== undefined) { tags.push(`offset-${sortBy}`); }
|
if (offset !== undefined) { tags.push(`offset-${offset}`); }
|
||||||
if (tag !== undefined) { tags.push(`tag-${sortBy}`); }
|
if (tag !== undefined) { tags.push(`tag-${tag}`); }
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
if (takenBefore !== undefined) { tags.push(`takenBefore-${takenBefore.toISOString()}`); }
|
if (takenBefore !== undefined) { tags.push(`takenBefore-${takenBefore.toISOString()}`); }
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
|||||||
@ -31,7 +31,11 @@ export default function MorePhotos({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const observer = new IntersectionObserver(e => {
|
const observer = new IntersectionObserver(e => {
|
||||||
if (triggerOnView && e[0].isIntersecting) {
|
if (
|
||||||
|
triggerOnView &&
|
||||||
|
e[0].isIntersecting &&
|
||||||
|
!isPending
|
||||||
|
) {
|
||||||
advance();
|
advance();
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
@ -42,7 +46,7 @@ export default function MorePhotos({
|
|||||||
observer.observe(buttonRef.current!);
|
observer.observe(buttonRef.current!);
|
||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, [triggerOnView, advance]);
|
}, [triggerOnView, advance, isPending]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user