Skip to content

Commit dcc81f7

Browse files
authored
Merge pull request #183 from MeshJS/bug/loading-issue
Bug/loading issue
2 parents e312c10 + fd1703a commit dcc81f7

File tree

12 files changed

+206
-272
lines changed

12 files changed

+206
-272
lines changed

src/components/common/button.tsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
import { Button as ShadcnButton } from "@/components/ui/button";
22
import { Loader } from "lucide-react";
3-
import { useState } from "react";
3+
import { useState, forwardRef } from "react";
4+
import type { ButtonProps as ShadcnButtonProps } from "@/components/ui/button";
45

5-
export default function Button({
6-
children,
7-
onClick,
8-
disabled = false,
9-
loading,
10-
className,
11-
variant,
12-
size,
13-
asChild,
14-
hold,
15-
}: {
6+
export interface ButtonProps {
167
children: React.ReactNode;
178
onClick?: () => void;
189
disabled?: boolean;
@@ -30,12 +21,26 @@ export default function Button({
3021
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
3122
asChild?: boolean | undefined;
3223
hold?: number;
33-
}) {
24+
}
25+
26+
const Button = forwardRef<HTMLButtonElement, ButtonProps & ShadcnButtonProps>(function Button({
27+
children,
28+
onClick,
29+
disabled = false,
30+
loading,
31+
className,
32+
variant,
33+
size,
34+
asChild,
35+
hold,
36+
...props
37+
}, ref) {
3438
const [holding, setHolding] = useState<boolean>(false);
3539
const [curTime, setCurTime] = useState<number>(0);
3640

3741
return (
3842
<ShadcnButton
43+
ref={ref}
3944
variant={variant}
4045
onClick={hold === undefined ? onClick : undefined}
4146
disabled={disabled}
@@ -61,6 +66,7 @@ export default function Button({
6166
}
6267
: undefined
6368
}
69+
{...props}
6470
>
6571
{loading && <Loader className="h-4 w-4 animate-spin mr-2" />}
6672
{children}
@@ -69,4 +75,6 @@ export default function Button({
6975
` (Hold for ${Math.round((hold - (Date.now() - curTime)) / 1000)} secs)`}
7076
</ShadcnButton>
7177
);
72-
}
78+
});
79+
80+
export default Button;

src/components/common/overall-layout/mobile-wrappers/wallet-data-loader-wrapper.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,14 @@ export default function WalletDataLoaderWrapper({
173173
);
174174
if (!drepInfo) throw new Error(`No dRep for ID ${drepids.cip105} found.`);
175175
setDrepInfo(drepInfo);
176-
} catch (err) {
176+
} catch (err: any) {
177177
// DRep not found (404) is expected if DRep hasn't been registered yet
178178
// This is normal behavior - the DRep ID exists but isn't registered on-chain
179+
const is404 = err?.response?.status === 404 || err?.data?.status_code === 404;
180+
if (!is404) {
181+
console.error(`Error fetching DRep info:`, err);
182+
}
179183
setDrepInfo(undefined);
180-
console.log(`DRep not yet registered on-chain (this is normal before registration)`);
181184
}
182185
}
183186

@@ -194,15 +197,13 @@ export default function WalletDataLoaderWrapper({
194197

195198
// Fetch all proxy data in parallel using the new batch function
196199
if (proxies.length > 0) {
197-
console.log(`WalletDataLoaderWrapper: Fetching data for ${proxies.length} proxies in parallel`);
198200
await fetchAllProxyData(
199201
appWallet.id,
200202
proxies,
201203
appWallet.scriptCbor,
202204
network.toString(),
203205
false // Use cache to avoid duplicate requests
204206
);
205-
console.log("WalletDataLoaderWrapper: Successfully fetched all proxy data");
206207
}
207208
} catch (error) {
208209
console.error("WalletDataLoaderWrapper: Error fetching proxy data:", error);

src/components/pages/homepage/governance/drep/id/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,21 @@ export default function DrepDetailPage() {
5858
metadata = await blockchainProvider.get(
5959
`/governance/dreps/${drepId}/metadata/`,
6060
);
61-
} catch {
62-
console.warn(`No metadata found for DRep ${drepId}`);
61+
} catch (err: any) {
62+
// 404 is expected if metadata doesn't exist - silently ignore
63+
const is404 = err?.response?.status === 404 || err?.data?.status_code === 404;
64+
if (!is404) {
65+
console.warn("No metadata found for DRep %s:", drepId, err);
66+
}
6367
}
6468

6569
setDrepInfo(details || null);
6670
setDrepMetadata(metadata || null);
67-
} catch (error) {
68-
console.error(`Failed to fetch DRep ${drepId} details:`, error);
71+
} catch (error: any) {
72+
const is404 = error?.response?.status === 404 || error?.data?.status_code === 404;
73+
if (!is404) {
74+
console.error("Failed to fetch DRep %s details:", drepId, error);
75+
}
6976
} finally {
7077
setLoading(false);
7178
}

src/components/pages/homepage/governance/drep/index.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ScriptIndicator from "./scriptIndicator";
1313

1414
export default function DrepOverviewPage() {
1515
const [drepList, setDrepList] = useState<
16-
Array<{ details: BlockfrostDrepInfo; metadata: BlockfrostDrepMetadata }>
16+
Array<{ details: BlockfrostDrepInfo; metadata: BlockfrostDrepMetadata | null }>
1717
>([]);
1818
const [loading, setLoading] = useState<boolean>(true);
1919
const { wallet, connected } = useWallet();
@@ -54,7 +54,7 @@ export default function DrepOverviewPage() {
5454
if (response) {
5555
const initialList = response.map((drep: BlockfrostDrepInfo) => ({
5656
details: { ...drep },
57-
metadata: {},
57+
metadata: null,
5858
}));
5959

6060
setDrepList(initialList);
@@ -85,17 +85,30 @@ export default function DrepOverviewPage() {
8585
const details: BlockfrostDrepInfo = await blockchainProvider.get(
8686
`/governance/dreps/${drepId}`,
8787
);
88-
const metadata: BlockfrostDrepMetadata = await blockchainProvider.get(
89-
`/governance/dreps/${drepId}/metadata/`,
90-
);
88+
89+
let metadata: BlockfrostDrepMetadata | null = null;
90+
try {
91+
metadata = await blockchainProvider.get(
92+
`/governance/dreps/${drepId}/metadata/`,
93+
);
94+
} catch (err: any) {
95+
// 404 is expected if metadata doesn't exist - silently ignore
96+
const is404 = err?.response?.status === 404 || err?.data?.status_code === 404;
97+
if (!is404) {
98+
console.warn(`Failed to fetch metadata for DRep ${drepId}:`, err);
99+
}
100+
}
91101

92102
setDrepList((prevList) =>
93103
prevList.map((drep) =>
94-
drep.details.drep_id === drepId ? { details, metadata } : drep,
104+
drep.details.drep_id === drepId ? { details, metadata: metadata || null } : drep,
95105
),
96106
);
97-
} catch (error) {
98-
console.error(`Failed to fetch details for DREP ${drepId}:`, error);
107+
} catch (error: any) {
108+
const is404 = error?.response?.status === 404 || error?.data?.status_code === 404;
109+
if (!is404) {
110+
console.error(`Failed to fetch details for DREP ${drepId}:`, error);
111+
}
99112
}
100113
};
101114

src/components/pages/homepage/wallets/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ export default function PageWallets() {
8282
.map((wallet) => {
8383
const walletBalance = balances[wallet.id] ?? null;
8484
const walletLoadingState = loadingStates[wallet.id] ?? "idle";
85-
// Debug log
86-
if (process.env.NODE_ENV === "development") {
87-
console.log(`Wallet ${wallet.id}: balance=${walletBalance}, loadingState=${walletLoadingState}`);
88-
}
8985
return (
9086
<CardWallet
9187
key={wallet.id}

src/components/pages/wallet/governance/proposal/voteButtton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
} from "@/components/ui/dialog";
3333
import type { BallotType } from "../ballot/ballot";
3434
import { useBallotModal } from "@/hooks/useBallotModal";
35-
import { Plus, Info, Lock, FileText, CheckCircle2, ClipboardList } from "lucide-react";
35+
import { Plus, Info, Lock, FileText, CheckCircle2, Vote } from "lucide-react";
3636
import { ProposalDetails } from "@/types/governance";
3737
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
3838

@@ -343,7 +343,7 @@ export default function VoteButton({
343343
}
344344

345345
return (
346-
<div className="flex w-full max-w-sm flex-col items-stretch justify-center space-y-2 sm:space-y-3">
346+
<div className="flex w-full flex-col items-stretch justify-center space-y-2 sm:space-y-3">
347347
{!isProposalActive ? (
348348
// Inactive proposal state
349349
<div className="flex flex-col items-center gap-2">
@@ -429,15 +429,15 @@ export default function VoteButton({
429429
>
430430
{isOnAnyBallot ? (
431431
<>
432-
<ClipboardList className="h-4 w-4" />
432+
<Vote className="h-4 w-4" />
433433
{ballotCount > 0 && (
434434
<span className="absolute -top-1 -right-1 h-4 w-4 flex items-center justify-center text-[10px] font-semibold bg-green-500 dark:bg-green-600 text-white rounded-full border-2 border-white dark:border-gray-800">
435435
{ballotCount}
436436
</span>
437437
)}
438438
</>
439439
) : (
440-
<ClipboardList className="h-4 w-4" />
440+
<Vote className="h-4 w-4" />
441441
)}
442442
</Button>
443443
</TooltipTrigger>

0 commit comments

Comments
 (0)