Skip to content

Commit

Permalink
fix(mobile): fix crash when click on asset item (trezor#10045)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodonisko authored Nov 24, 2023
1 parent 892dd06 commit 73f0b26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
13 changes: 0 additions & 13 deletions suite-common/wallet-core/src/accounts/accountsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,6 @@ export const selectAccountKeyByDescriptorAndNetworkSymbol = (
return account?.key ?? null;
};

export const selectAccountsAmountPerSymbol = (
state: AccountsRootState & DeviceRootState,
networkSymbol: NetworkSymbol,
) => {
const accounts = selectDeviceAccounts(state);

return pipe(
accounts,
A.filter(account => account.symbol === networkSymbol),
A.length,
);
};

export const selectAccountsSymbols = memoize(
(state: AccountsRootState): NetworkSymbol[] =>
pipe(
Expand Down
21 changes: 6 additions & 15 deletions suite-native/assets/src/components/AssetItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import { useSelector } from 'react-redux';
import { useNavigation } from '@react-navigation/native';

import { CryptoIconName, CryptoIconWithPercentage, Icon } from '@suite-common/icons';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { Box, Text } from '@suite-native/atoms';
import {
AccountsRootState,
selectAccountsAmountPerSymbol,
selectAccountsByNetworkAndDevice,
PORTFOLIO_TRACKER_DEVICE_STATE,
DeviceRootState,
selectAccountsByNetworkSymbol,
} from '@suite-common/wallet-core';
import { Box, Text } from '@suite-native/atoms';
import { CryptoAmountFormatter, FiatAmountFormatter } from '@suite-native/formatters';
import {
AppTabsParamList,
Expand All @@ -23,6 +20,7 @@ import {
RootStackRoutes,
TabToStackCompositeNavigationProp,
} from '@suite-native/navigation';
import { prepareNativeStyle, useNativeStyles } from '@trezor/styles';

type AssetItemProps = {
cryptoCurrencySymbol: NetworkSymbol;
Expand Down Expand Up @@ -72,19 +70,12 @@ export const AssetItem = memo(
onPress,
}: AssetItemProps) => {
const { applyStyle } = useNativeStyles();

const navigation = useNavigation<NavigationType>();

const accountsPerAsset = useSelector((state: AccountsRootState & DeviceRootState) =>
selectAccountsAmountPerSymbol(state, cryptoCurrencySymbol),
);
const accountsForNetworkSymbol = useSelector((state: AccountsRootState) =>
selectAccountsByNetworkAndDevice(
state,
PORTFOLIO_TRACKER_DEVICE_STATE,
cryptoCurrencySymbol,
),
const accountsForNetworkSymbol = useSelector((state: AccountsRootState & DeviceRootState) =>
selectAccountsByNetworkSymbol(state, cryptoCurrencySymbol),
);
const accountsPerAsset = accountsForNetworkSymbol.length;

const handleAssetPress = () => {
if (accountsPerAsset === 1) {
Expand Down

0 comments on commit 73f0b26

Please sign in to comment.