Skip to content

Commit df7ab3a

Browse files
committed
chore: do not dim tokens when no wallet is selected
1 parent a3c6389 commit df7ab3a

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

src/views/v3/Bridge/AssetPicker/TokenList.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,28 +115,27 @@ const TokenList = (props: Props) => {
115115

116116
// Normal state - show the token list
117117
return 'ready';
118-
}, [
119-
props.isSource,
120-
props.wallet?.address,
121-
props.isConnectingWallet,
122-
props.isFetching,
123-
sortedTokens.length,
124-
]);
118+
}, [props.isFetching, sortedTokens.length]);
125119

126120
const shouldShowLoadingState = listState === 'loading';
127121
const shouldShowEmptyMessage = listState === 'empty';
128122

129123
// Build sectioned list for source picker when not searching
130124
const isGroupingEnabled = props.isSource && !props.searchQuery;
125+
const isWalletConnected = Boolean(props.wallet?.address);
131126

132127
const { itemsForRender, ownedCount } = useMemo(() => {
133128
if (!isGroupingEnabled) {
134129
return { itemsForRender: sortedTokens, ownedCount: 0 };
135130
}
136131

137132
const hasPositiveBalance = (token: Token) => {
133+
if (!isWalletConnected) {
134+
return false;
135+
}
136+
138137
const bal = props.balances?.[token.key]?.balance;
139-
return !!(bal && sdkAmount.units(bal) > 0n);
138+
return Boolean(bal && sdkAmount.units(bal) > 0n);
140139
};
141140

142141
const nativeToken = sortedTokens.find((token) => token.isNativeGasToken);
@@ -154,7 +153,7 @@ const TokenList = (props: Props) => {
154153
const itemsForRender = [...ownedTokens, ...nativePart, ...rest];
155154

156155
return { itemsForRender, ownedCount: ownedTokens.length };
157-
}, [isGroupingEnabled, props.balances, sortedTokens]);
156+
}, [isGroupingEnabled, isWalletConnected, props.balances, sortedTokens]);
158157

159158
const searchList = (
160159
<SearchableList<Token>
@@ -185,7 +184,9 @@ const TokenList = (props: Props) => {
185184
? getUSDFormat(calculateUSDPriceRaw(tokenPrice, balance, token))
186185
: null;
187186

188-
const isRestSection = isGroupingEnabled && index >= ownedCount;
187+
// Do not dim when no wallet is connected
188+
const isRestSection =
189+
isGroupingEnabled && isWalletConnected && index >= ownedCount;
189190

190191
return (
191192
<Fragment key={token.key}>

0 commit comments

Comments
 (0)