mirror of
https://github.com/zhigang1992/wallet.git
synced 2026-01-12 22:53:27 +08:00
fix: infinite loading bug, closes #3783
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user