Skip to content

Commit

Permalink
fix(activity): fix tabs and WalletDetail screen filter
Browse files Browse the repository at this point in the history
  • Loading branch information
pwltr committed Aug 20, 2023
1 parent 65d6669 commit 46dbb98
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 30 deletions.
5 changes: 2 additions & 3 deletions e2e/lightning.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 6 additions & 2 deletions src/screens/Activity/ActivityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -53,7 +57,7 @@ const ActivityList = ({
contentContainerStyle?: StyleProp<ViewStyle>;
progressViewOffset?: number;
showTitle?: boolean;
filter?: {};
filter?: TActivityFilter;
onScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
}): ReactElement => {
const { t } = useTranslation('wallet');
Expand Down
21 changes: 6 additions & 15 deletions src/screens/Wallets/WalletsDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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],
Expand All @@ -115,6 +106,10 @@ const WalletsDetail = ({
updateHeight({ height, toValue: headerHeight });
}, [height, headerHeight]);

const toggleHideBalance = (): void => {
updateSettings({ hideBalance: !hideBalance });
};

const onScroll = useCallback(
(e: NativeSyntheticEvent<NativeScrollEvent>) => {
const { y } = e.nativeEvent.contentOffset;
Expand All @@ -136,10 +131,6 @@ const WalletsDetail = ({
[showDetails, height, headerHeight],
);

const toggleHideBalance = (): void => {
updateSettings({ hideBalance: !hideBalance });
};

return (
<AnimatedView style={styles.container}>
<View color="transparent" style={styles.txListContainer}>
Expand All @@ -148,7 +139,7 @@ const WalletsDetail = ({
style={styles.txList}
contentContainerStyle={activityPadding}
progressViewOffset={radiusContainerHeight + 10}
filter={filter}
filter={{ includeTransfers: true }}
/>
</View>
<View color="transparent" style={styles.radiusContainer}>
Expand Down
14 changes: 4 additions & 10 deletions src/utils/activity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 46dbb98

Please sign in to comment.