Skip to content

Commit d85e8fa

Browse files
committed
build fix
1 parent 06548ad commit d85e8fa

File tree

8 files changed

+194
-232
lines changed

8 files changed

+194
-232
lines changed

src/components/common/overall-layout/proxy-data-loader.tsx

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { useEffect } from "react";
22
import useAppWallet from "@/hooks/useAppWallet";
3-
import { useProxyStore, useProxyData, useProxyActions } from "@/lib/zustand/proxy";
3+
import { useProxyData, useProxyActions } from "@/lib/zustand/proxy";
44
import { useSiteStore } from "@/lib/zustand/site";
55
import { api } from "@/utils/api";
66

77
export default function ProxyDataLoader() {
88
const { appWallet } = useAppWallet();
99
const network = useSiteStore((state) => state.network);
10-
const { proxies, loading, error } = useProxyData(appWallet?.id);
10+
const { proxies } = useProxyData(appWallet?.id);
1111
const {
1212
setProxies,
1313
fetchProxyBalance,
@@ -18,9 +18,9 @@ export default function ProxyDataLoader() {
1818

1919

2020
// Get proxies from API
21-
const { data: apiProxies, refetch: refetchProxies, isLoading: apiLoading } = api.proxy.getProxiesByUserOrWallet.useQuery(
21+
const { data: apiProxies, refetch: refetchProxies } = api.proxy.getProxiesByUserOrWallet.useQuery(
2222
{
23-
walletId: appWallet?.id || undefined,
23+
walletId: appWallet?.id ?? undefined,
2424
},
2525
{
2626
enabled: !!appWallet?.id,
@@ -49,36 +49,29 @@ export default function ProxyDataLoader() {
4949

5050
// Fetch additional data for each proxy
5151
useEffect(() => {
52-
5352
if (proxies.length > 0 && appWallet?.id && appWallet?.scriptCbor) {
54-
proxies.forEach(async (proxy) => {
55-
// Only fetch if we don't have recent data (older than 5 minutes)
56-
const isStale = !proxy.lastUpdated || (Date.now() - proxy.lastUpdated) > 5 * 60 * 1000;
57-
58-
59-
if (isStale) {
60-
try {
61-
62-
// Fetch balance
63-
await fetchProxyBalance(appWallet.id, proxy.id, proxy.proxyAddress, network.toString());
64-
65-
// Fetch DRep info
66-
await fetchProxyDrepInfo(
67-
appWallet.id,
68-
proxy.id,
69-
proxy.proxyAddress,
70-
proxy.authTokenId,
71-
appWallet.scriptCbor,
72-
network.toString(),
73-
proxy.paramUtxo
74-
);
75-
76-
77-
} catch (error) {
78-
console.error(`Error fetching data for proxy ${proxy.id}:`, error);
53+
void (async () => {
54+
for (const proxy of proxies) {
55+
// Only fetch if we don't have recent data (older than 5 minutes)
56+
const isStale = !proxy.lastUpdated || (Date.now() - proxy.lastUpdated) > 5 * 60 * 1000;
57+
if (isStale) {
58+
try {
59+
await fetchProxyBalance(appWallet.id, proxy.id, proxy.proxyAddress, network.toString());
60+
await fetchProxyDrepInfo(
61+
appWallet.id,
62+
proxy.id,
63+
proxy.proxyAddress,
64+
proxy.authTokenId,
65+
appWallet.scriptCbor,
66+
network.toString(),
67+
proxy.paramUtxo,
68+
);
69+
} catch (error) {
70+
console.error(`Error fetching data for proxy ${proxy.id}:`, error);
71+
}
7972
}
8073
}
81-
});
74+
})();
8275
}
8376
}, [proxies, appWallet?.id, appWallet?.scriptCbor, network, fetchProxyBalance, fetchProxyDrepInfo]);
8477

@@ -95,7 +88,10 @@ export default function ProxyDataLoader() {
9588
useEffect(() => {
9689
// Store refetch function in window for global access if needed
9790
if (typeof window !== 'undefined') {
98-
(window as any).refetchProxyData = refetchProxies;
91+
const w = window as Window & { refetchProxyData?: () => void };
92+
w.refetchProxyData = () => {
93+
void refetchProxies();
94+
};
9995
}
10096
}, [refetchProxies]);
10197

0 commit comments

Comments
 (0)