Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions apps/cross-chain-accounts/components/AccountBlobs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,42 @@ interface AccountBlobsProps {
export const AccountBlobs = ({ refreshTrigger }: AccountBlobsProps) => {
const { account } = useWallet();
const [blobs, setBlobs] = useState<BlobMetadata[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
if (!account) {
setBlobs([]);
setError(null);
return;
}
const getBlobs = async (): Promise<BlobMetadata[]> => {
const blobs = await getShelbyClient().coordination.getAccountBlobs({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty state flashes before loading

Low Severity

isLoading starts as false and is left unchanged when account is missing, so the first paint after a wallet connect has no loading flag, no error, and empty blobs. The empty-state copy is shown until useEffect later sets isLoading. With autoConnect this flicker happens on page load and again on every reconnect.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6399d11. Configure here.

account: account.address,
});
return blobs;

let cancelled = false;
const getBlobs = async (): Promise<void> => {
setIsLoading(true);
setError(null);
try {
const fetched = await getShelbyClient().coordination.getAccountBlobs({
account: account.address,
});
if (!cancelled) setBlobs(fetched);
} catch (err) {
if (!cancelled) {
const message =
err instanceof Error ? err.message : "Failed to fetch blobs";
setError(message);
setBlobs([]);
}
} finally {
if (!cancelled) setIsLoading(false);
}
};

getBlobs().then((blobs) => {
setBlobs(blobs);
refreshTrigger;
});
getBlobs();

return () => {
cancelled = true;
};
}, [account, refreshTrigger]);

const extractFileName = (blobName: string): string => {
Expand All @@ -49,7 +68,17 @@ export const AccountBlobs = ({ refreshTrigger }: AccountBlobsProps) => {
</p>
</div>
)}
{account && blobs.length === 0 && (
{account && isLoading && (
<div className="text-center py-8">
<p className="text-gray-500 dark:text-gray-400">Loading blobs...</p>
</div>
)}
{account && error && !isLoading && (
<div className="text-center py-8">
<p className="text-red-500 dark:text-red-400">{error}</p>
</div>
)}
{account && !isLoading && !error && blobs.length === 0 && (
<div className="text-center py-8">
<p className="text-gray-500 dark:text-gray-400">
No blobs found for this account. Upload a file to get started!
Expand Down