Skip to content

Commit abb91f2

Browse files
fix: deduplicate wallets in all-wallets view
1 parent e6fa8a9 commit abb91f2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

packages/scaffold/src/partials/w3m-all-wallets-list/index.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ export function AllWalletsList({ columns, itemWidth, onItemPress }: AllWalletsLi
3838
const preloadedWallets = installed.length + featured.length + recommended.length;
3939
const loadingItems = columns - ((100 + preloadedWallets) % columns);
4040

41-
const walletList = [
41+
const combinedWallets = [
4242
...(customWallets ?? []),
4343
...installed,
4444
...featured,
4545
...recommended,
46-
...wallets,
46+
...wallets
47+
];
48+
49+
// Deduplicate by wallet ID
50+
const uniqueWallets = Array.from(
51+
new Map(combinedWallets.map(wallet => [wallet?.id, wallet])).values()
52+
).filter(wallet => wallet?.id); // Filter out any undefined wallets
53+
54+
const walletList = [
55+
...uniqueWallets,
4756
...(pageLoading ? (Array.from({ length: loadingItems }) as WcWallet[]) : [])
4857
];
4958

@@ -132,7 +141,7 @@ export function AllWalletsList({ columns, itemWidth, onItemPress }: AllWalletsLi
132141
<Placeholder
133142
icon="warningCircle"
134143
iconColor="error-100"
135-
title="Oops, we couldnt load the wallets at the moment"
144+
title="Oops, we couldn't load the wallets at the moment"
136145
description={`This might be due to a temporary network issue.\nPlease try reloading to see if that helps.`}
137146
actionIcon="refresh"
138147
actionPress={initialFetch}

packages/scaffold/src/views/w3m-connect-view/components/all-wallet-list.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ export function AllWalletList({ itemStyle, onWalletPress, isWalletConnectEnabled
2323
const imageHeaders = ApiController._getApiHeaders();
2424
const RECENT_COUNT = recentWallets?.length && installed.length ? 1 : recentWallets?.length ?? 0;
2525

26-
const list = filterOutRecentWallets(
27-
recentWallets,
28-
[...installed, ...featured, ...recommended],
29-
RECENT_COUNT
30-
).slice(0, UiUtil.TOTAL_VISIBLE_WALLETS - RECENT_COUNT);
26+
const combinedWallets = [...installed, ...featured, ...recommended];
27+
28+
// Deduplicate by wallet ID
29+
const uniqueWallets = Array.from(
30+
new Map(combinedWallets.map(wallet => [wallet.id, wallet])).values()
31+
);
32+
33+
const list = filterOutRecentWallets(recentWallets, uniqueWallets, RECENT_COUNT).slice(
34+
0,
35+
UiUtil.TOTAL_VISIBLE_WALLETS - RECENT_COUNT
36+
);
3137

3238
if (!isWalletConnectEnabled || !list?.length) {
3339
return null;

0 commit comments

Comments
 (0)