Skip to content

Commit 0601460

Browse files
committed
disable loading more locally
1 parent 0f6ef98 commit 0601460

2 files changed

Lines changed: 32 additions & 22 deletions

File tree

packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/observe/TransactionsTable.tsx

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import {
1818
} from "../../../../../../components/ui/Table";
1919
import { TruncatedHex } from "../../../../../../components/ui/TruncatedHex";
2020
import { cn } from "../../../../../../utils";
21+
import { useChain } from "../../../../hooks/useChain";
2122
import { useTransactionsQuery } from "../../../../queries/useTransactionsQuery";
23+
import { indexerForChainId } from "../../../../utils/indexerForChainId";
2224
import { BlockExplorerLink } from "./BlockExplorerLink";
2325
import { TimeAgo } from "./TimeAgo";
2426
import { TimingRowHeader } from "./TimingRowHeader";
@@ -113,6 +115,8 @@ export const columns = [
113115

114116
export function TransactionsTable() {
115117
const { ref, inView } = useInView();
118+
const { id: chainId } = useChain();
119+
const indexer = indexerForChainId(chainId);
116120
const transactions = useMergedTransactions();
117121
const { isLoading, fetchNextPage } = useTransactionsQuery();
118122
const [expanded, setExpanded] = useState<ExpandedState>({});
@@ -165,26 +169,28 @@ export function TransactionsTable() {
165169
)}
166170
</TableBody>
167171

168-
<TableFooter
169-
className={cn("border-t-transparent bg-transparent hover:bg-transparent", { "border-t-muted": !isLoading })}
170-
>
171-
<TableRow>
172-
<TableCell colSpan={columns.length}>
173-
<div
174-
ref={ref}
175-
className={cn(
176-
"hidden items-center justify-center gap-3 py-4 font-mono text-xs font-bold uppercase text-muted-foreground",
177-
{
178-
flex: !isLoading,
179-
},
180-
)}
181-
>
182-
<span className="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-muted-foreground" />
183-
Loading more transactions...
184-
</div>
185-
</TableCell>
186-
</TableRow>
187-
</TableFooter>
172+
{indexer.type === "hosted" && (
173+
<TableFooter
174+
className={cn("border-t-transparent bg-transparent hover:bg-transparent", { "border-t-muted": !isLoading })}
175+
>
176+
<TableRow>
177+
<TableCell colSpan={columns.length}>
178+
<div
179+
ref={ref}
180+
className={cn(
181+
"hidden items-center justify-center gap-3 py-4 font-mono text-xs font-bold uppercase text-muted-foreground",
182+
{
183+
flex: !isLoading,
184+
},
185+
)}
186+
>
187+
<span className="inline-block h-1.5 w-1.5 animate-ping rounded-full bg-muted-foreground" />
188+
Loading more transactions...
189+
</div>
190+
</TableCell>
191+
</TableRow>
192+
</TableFooter>
193+
)}
188194
</Table>
189195
);
190196
}

packages/explorer/src/app/(explorer)/queries/useTransactionsQuery.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ export function useTransactionsQuery() {
3131
},
3232

3333
initialPageParam: 0,
34-
getNextPageParam: (lastPage) => lastPage.transactions[lastPage.transactions.length - 1].block_num,
34+
getNextPageParam: (lastPage) => {
35+
if (!lastPage?.transactions?.length) return null;
36+
const lastTransaction = lastPage.transactions[lastPage.transactions.length - 1];
37+
return lastTransaction?.block_num ?? null;
38+
},
3539
select: (data) => data.pages[data.pages.length - 1].transactions,
3640
retry: false,
37-
enabled: !!worldAddress && indexer.type === "hosted",
41+
enabled: indexer.type === "hosted",
3842
refetchInterval: (query) => (!query.state.error ? 2000 : false),
3943
});
4044
}

0 commit comments

Comments
 (0)