fix: infinite loading bug, closes #3783

This commit is contained in:
alter-eggo
2023-05-31 17:45:28 +04:00
committed by Anastasios
parent bc4e1800f6
commit dd3d218555
2 changed files with 3 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ export function Ordinals({ setIsLoadingMore }: OrdinalsProps) {
const intersectionSentinel = useRef<HTMLDivElement | null>(null);
async function fetchNextPage() {
if (!query.hasNextPage) return;
if (!query.hasNextPage || query.isLoading) return;
try {
setIsLoadingMore(true);
await query.fetchNextPage();

View File

@@ -128,7 +128,8 @@ export function useTaprootInscriptionsInfiniteQuery() {
const results = responsesArr.flatMap(response => response.results);
// get offset and total from the last response
const { offset, total } = responsesArr[responsesArr.length - 1];
const offset = responsesArr[responsesArr.length - 1]?.offset;
const total = responsesArr[responsesArr.length - 1]?.total;
return {
offset: pageParam?.offset ?? offset,
@@ -153,11 +154,6 @@ export function useTaprootInscriptionsInfiniteQuery() {
calculatedOffset = offset + (total - offset);
}
// if we reached the end of the list, start from the beginning
if (calculatedOffset >= total) {
calculatedOffset = 0;
}
return { offset: calculatedOffset, total };
},
staleTime: 3 * 60 * 1000,