Skip to content

Commit

Permalink
When dismissing the error dialog for balance fetch failures, don't sh…
Browse files Browse the repository at this point in the history
…ow it again
  • Loading branch information
steveluscher committed Jun 25, 2024
1 parent 385fd04 commit 53decb0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/react-app/src/components/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ type Props = Readonly<{
account: UiWalletAccount;
}>;

const seenErrors = new WeakSet();

export function Balance({ account }: Props) {
const { chain } = useContext(ChainContext);
const { rpc, rpcSubscriptions } = useContext(RpcContext);
const subscribe = useMemo(() => balanceSubscribe.bind(null, rpc, rpcSubscriptions), [rpc, rpcSubscriptions]);
const { data: lamports, error } = useSWRSubscription({ address: address(account.address), chain }, subscribe);
if (error) {
if (error && !seenErrors.has(error)) {
return (
<>
<ErrorDialog
error={error}
key={`${account.address}:${chain}`}
onClose={() => {
seenErrors.add(error);
}}
title="Failed to fetch account balance"
/>
<Text>
Expand Down

0 comments on commit 53decb0

Please sign in to comment.