Fix explorer bugs (#11336)
* Fix race condition in explorer details fetching * Fix SOL delta rendering bug
This commit is contained in:
parent
4052008c42
commit
433f262290
|
@ -20,6 +20,7 @@ import {
|
|||
useFetchAccountOwnedTokens,
|
||||
useAccountOwnedTokens,
|
||||
} from "providers/accounts/tokens";
|
||||
import { useCluster, ClusterStatus } from "providers/cluster";
|
||||
|
||||
type Props = { address: string };
|
||||
export default function AccountDetails({ address }: Props) {
|
||||
|
@ -51,11 +52,13 @@ function AccountCards({ pubkey }: { pubkey: PublicKey }) {
|
|||
const address = pubkey.toBase58();
|
||||
const info = useAccountInfo(address);
|
||||
const refresh = useFetchAccountInfo();
|
||||
const { status } = useCluster();
|
||||
|
||||
// Fetch account on load
|
||||
React.useEffect(() => {
|
||||
if (pubkey && !info) fetchAccount(pubkey);
|
||||
}, [address]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
if (pubkey && !info && status === ClusterStatus.Connected)
|
||||
fetchAccount(pubkey);
|
||||
}, [address, status]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (!info || info.status === FetchStatus.Fetching) {
|
||||
return <LoadingCard />;
|
||||
|
|
|
@ -6,7 +6,7 @@ import {
|
|||
FetchStatus,
|
||||
} from "../providers/transactions";
|
||||
import { useFetchTransactionDetails } from "providers/transactions/details";
|
||||
import { useCluster } from "providers/cluster";
|
||||
import { useCluster, ClusterStatus } from "providers/cluster";
|
||||
import {
|
||||
TransactionSignature,
|
||||
SystemProgram,
|
||||
|
@ -49,12 +49,13 @@ function StatusCard({ signature }: Props) {
|
|||
const status = useTransactionStatus(signature);
|
||||
const refresh = useFetchTransactionStatus();
|
||||
const details = useTransactionDetails(signature);
|
||||
const { firstAvailableBlock } = useCluster();
|
||||
const { firstAvailableBlock, status: clusterStatus } = useCluster();
|
||||
|
||||
// Fetch transaction on load
|
||||
React.useEffect(() => {
|
||||
if (!status) fetchStatus(signature);
|
||||
}, [signature]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
if (!status && clusterStatus === ClusterStatus.Connected)
|
||||
fetchStatus(signature);
|
||||
}, [signature, clusterStatus]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
if (!status || status.fetchStatus === FetchStatus.Fetching) {
|
||||
return <LoadingCard />;
|
||||
|
@ -229,9 +230,9 @@ function AccountsCard({ signature }: Props) {
|
|||
if (change === 0) return "";
|
||||
const sols = lamportsToSolString(change);
|
||||
if (change > 0) {
|
||||
return <span className="badge badge-soft-success">{"+" + sols}</span>;
|
||||
return <span className="badge badge-soft-success">+{sols}</span>;
|
||||
} else {
|
||||
return <span className="badge badge-soft-warning">{"-" + sols}</span>;
|
||||
return <span className="badge badge-soft-warning">-{sols}</span>;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue