diff --git a/src/cache/index.ts b/src/cache/index.ts index a3e9af55..39da6d0d 100644 --- a/src/cache/index.ts +++ b/src/cache/index.ts @@ -26,9 +26,9 @@ const getPhotosCacheTags = (options: GetPhotosOptions = {}) => { } = options; if (sortBy !== undefined) { tags.push(`sortBy-${sortBy}`); } - if (limit !== undefined) { tags.push(`limit-${sortBy}`); } - if (offset !== undefined) { tags.push(`offset-${sortBy}`); } - if (tag !== undefined) { tags.push(`tag-${sortBy}`); } + if (limit !== undefined) { tags.push(`limit-${limit}`); } + if (offset !== undefined) { tags.push(`offset-${offset}`); } + if (tag !== undefined) { tags.push(`tag-${tag}`); } // eslint-disable-next-line max-len if (takenBefore !== undefined) { tags.push(`takenBefore-${takenBefore.toISOString()}`); } // eslint-disable-next-line max-len diff --git a/src/components/MorePhotos.tsx b/src/components/MorePhotos.tsx index 2774eebf..dadcd616 100644 --- a/src/components/MorePhotos.tsx +++ b/src/components/MorePhotos.tsx @@ -31,7 +31,11 @@ export default function MorePhotos({ useEffect(() => { const observer = new IntersectionObserver(e => { - if (triggerOnView && e[0].isIntersecting) { + if ( + triggerOnView && + e[0].isIntersecting && + !isPending + ) { advance(); } }, { @@ -42,7 +46,7 @@ export default function MorePhotos({ observer.observe(buttonRef.current!); return () => observer.disconnect(); - }, [triggerOnView, advance]); + }, [triggerOnView, advance, isPending]); return (