Skip to content

Commit 339a37e

Browse files
committed
refactor and deduplicate external wallets
1 parent 892bbaf commit 339a37e

File tree

1 file changed

+8
-14
lines changed
  • packages/modal/src/ui/components/Root

1 file changed

+8
-14
lines changed

packages/modal/src/ui/components/Root/Root.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -336,26 +336,20 @@ function Root(props: RootProps) {
336336
.slice(0, displayInstalledExternalWallets ? MAX_TOP_INSTALLED_CONNECTORS : 1);
337337
}, [installedConnectorButtons, displayInstalledExternalWallets]);
338338

339-
const totalExternalWallets = useMemo(() => {
340-
const uniqueWalletSet = new Set();
341-
return allRegistryButtons.concat(installedConnectorButtons).filter((button) => {
342-
if (uniqueWalletSet.has(button.name)) return false;
343-
uniqueWalletSet.add(button.name);
344-
return true;
345-
}).length;
346-
}, [allRegistryButtons, installedConnectorButtons]);
347-
348-
const remainingUndisplayedWallets = useMemo(() => {
339+
const allExternalWallets = useMemo(() => {
349340
const uniqueButtonSet = new Set();
350-
const uniqueButtons = installedConnectorButtons.concat(allRegistryButtons).filter((button) => {
341+
return installedConnectorButtons.concat(allRegistryButtons).filter((button) => {
351342
if (uniqueButtonSet.has(button.name)) return false;
352343
uniqueButtonSet.add(button.name);
353344
return true;
354345
});
355-
return uniqueButtons.filter((button) => {
346+
}, [allRegistryButtons, installedConnectorButtons]);
347+
348+
const remainingUndisplayedWallets = useMemo(() => {
349+
return allExternalWallets.filter((button) => {
356350
return !topInstalledConnectorButtons.includes(button);
357351
}).length;
358-
}, [installedConnectorButtons, allRegistryButtons, topInstalledConnectorButtons]);
352+
}, [allExternalWallets, topInstalledConnectorButtons]);
359353

360354
const handleSocialLoginHeight = () => {
361355
setIsSocialLoginsExpanded((prev) => !prev);
@@ -493,7 +487,7 @@ function Root(props: RootProps) {
493487
installedExternalWalletConfig={topInstalledConnectorButtons}
494488
isEmailPasswordLessLoginVisible={isEmailPasswordLessLoginVisible}
495489
isSmsPasswordLessLoginVisible={isSmsPasswordLessLoginVisible}
496-
totalExternalWallets={totalExternalWallets}
490+
totalExternalWallets={allExternalWallets.length}
497491
remainingUndisplayedWallets={remainingUndisplayedWallets}
498492
logoAlignment={logoAlignment}
499493
buttonRadius={buttonRadiusType}

0 commit comments

Comments
 (0)