From 46dbb989287386871f623fc9beedff8b7238de19 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Sat, 19 Aug 2023 14:37:31 +0200 Subject: [PATCH] fix(activity): fix tabs and WalletDetail screen filter --- e2e/lightning.e2e.js | 5 ++--- src/screens/Activity/ActivityList.tsx | 8 ++++++-- src/screens/Wallets/WalletsDetail/index.tsx | 21 ++++++--------------- src/utils/activity/index.ts | 14 ++++---------- 4 files changed, 18 insertions(+), 30 deletions(-) diff --git a/e2e/lightning.e2e.js b/e2e/lightning.e2e.js index 7118efce1..8738f876c 100644 --- a/e2e/lightning.e2e.js +++ b/e2e/lightning.e2e.js @@ -299,9 +299,8 @@ d('Lightning', () => { await expect(element(by.id('Activity-3'))).not.toExist(); // Other, 0 transactions - // TODO: fixed in another PR - // await element(by.id('Tab-other')).tap(); - // await expect(element(by.id('Activity-1'))).not.toExist(); + await element(by.id('Tab-other')).tap(); + await expect(element(by.id('Activity-1'))).not.toExist(); // filter by receive tag await element(by.id('Tab-all')).tap(); diff --git a/src/screens/Activity/ActivityList.tsx b/src/screens/Activity/ActivityList.tsx index d06fab8d5..dd077a080 100644 --- a/src/screens/Activity/ActivityList.tsx +++ b/src/screens/Activity/ActivityList.tsx @@ -24,7 +24,11 @@ import { useTranslation } from 'react-i18next'; import { Caption13Up, Subtitle, Text01S } from '../../styles/text'; import { refreshWallet } from '../../utils/wallet'; -import { groupActivityItems, filterActivityItems } from '../../utils/activity'; +import { + groupActivityItems, + filterActivityItems, + TActivityFilter, +} from '../../utils/activity'; import ListItem from './ListItem'; import { RootNavigationProp } from '../../navigation/types'; import { activityItemsSelector } from '../../store/reselect/activity'; @@ -53,7 +57,7 @@ const ActivityList = ({ contentContainerStyle?: StyleProp; progressViewOffset?: number; showTitle?: boolean; - filter?: {}; + filter?: TActivityFilter; onScroll?: (event: NativeSyntheticEvent) => void; }): ReactElement => { const { t } = useTranslation('wallet'); diff --git a/src/screens/Wallets/WalletsDetail/index.tsx b/src/screens/Wallets/WalletsDetail/index.tsx index 829f75b87..20480ecca 100644 --- a/src/screens/Wallets/WalletsDetail/index.tsx +++ b/src/screens/Wallets/WalletsDetail/index.tsx @@ -44,12 +44,11 @@ import BitcoinBreakdown from './BitcoinBreakdown'; import SafeAreaInset from '../../../components/SafeAreaInset'; import Money from '../../../components/Money'; import BlurView from '../../../components/BlurView'; -import { EActivityType } from '../../../store/types/activity'; import { updateSettings } from '../../../store/actions/settings'; +import { hideBalanceSelector } from '../../../store/reselect/settings'; import { capitalize } from '../../../utils/helpers'; import DetectSwipe from '../../../components/DetectSwipe'; import type { WalletScreenProps } from '../../../navigation/types'; -import { hideBalanceSelector } from '../../../store/reselect/settings'; const updateHeight = ({ height, toValue = 0, duration = 250 }): void => { try { @@ -98,14 +97,6 @@ const WalletsDetail = ({ const [headerHeight, setHeaderHeight] = useState(0); const height = useSharedValue(0); - const filter = useMemo(() => { - const types = - assetType === 'bitcoin' - ? [EActivityType.onchain, EActivityType.lightning] - : [EActivityType.tether]; - return { types }; - }, [assetType]); - const activityPadding = useMemo( () => ({ paddingTop: radiusContainerHeight, paddingBottom: 230 }), [radiusContainerHeight], @@ -115,6 +106,10 @@ const WalletsDetail = ({ updateHeight({ height, toValue: headerHeight }); }, [height, headerHeight]); + const toggleHideBalance = (): void => { + updateSettings({ hideBalance: !hideBalance }); + }; + const onScroll = useCallback( (e: NativeSyntheticEvent) => { const { y } = e.nativeEvent.contentOffset; @@ -136,10 +131,6 @@ const WalletsDetail = ({ [showDetails, height, headerHeight], ); - const toggleHideBalance = (): void => { - updateSettings({ hideBalance: !hideBalance }); - }; - return ( @@ -148,7 +139,7 @@ const WalletsDetail = ({ style={styles.txList} contentContainerStyle={activityPadding} progressViewOffset={radiusContainerHeight + 10} - filter={filter} + filter={{ includeTransfers: true }} /> diff --git a/src/utils/activity/index.ts b/src/utils/activity/index.ts index b1110ad8c..2c7da1c2d 100644 --- a/src/utils/activity/index.ts +++ b/src/utils/activity/index.ts @@ -176,20 +176,14 @@ export const filterActivityItems = ( } // If we're not including transfers and it's a transfer, skip it - if ( - !includeTransfers && - item.activityType === EActivityType.onchain && - item.isTransfer - ) { + // @ts-ignore + if (!includeTransfers && item.isTransfer) { return false; } // If we're only including transfers and it's not a transfer, skip it - if ( - onlyTransfers && - item.activityType === EActivityType.onchain && - !item.isTransfer - ) { + // @ts-ignore + if (onlyTransfers && !item.isTransfer) { return false; }