Skip to content

Commit 7b9226c

Browse files
committed
fix(activity): fix icon & description for boosted transfers
1 parent 293f52a commit 7b9226c

File tree

3 files changed

+58
-35
lines changed

3 files changed

+58
-35
lines changed

src/screens/Activity/ActivityDetail.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,24 +313,6 @@ const OnchainActivityDetail = ({
313313
</ThemedView>
314314
);
315315

316-
if (isBoosted) {
317-
status = (
318-
<View testID="StatusBoosting" style={styles.row}>
319-
<TimerIconAlt style={styles.rowIcon} color="yellow" height={14} />
320-
<BodySSB color="yellow">{t('activity_boosting')}</BodySSB>
321-
</View>
322-
);
323-
}
324-
325-
if (confirmed) {
326-
status = (
327-
<View testID="StatusConfirmed" style={styles.row}>
328-
<CheckCircleIcon style={styles.rowIcon} color="green" />
329-
<BodySSB color="green">{t('activity_confirmed')}</BodySSB>
330-
</View>
331-
);
332-
}
333-
334316
if (transfer) {
335317
fees = value - transfer.amount + fee;
336318
paymentAmount = transfer.amount;
@@ -353,6 +335,24 @@ const OnchainActivityDetail = ({
353335
);
354336
}
355337

338+
if (isBoosted) {
339+
status = (
340+
<View testID="StatusBoosting" style={styles.row}>
341+
<TimerIconAlt style={styles.rowIcon} color="yellow" height={14} />
342+
<BodySSB color="yellow">{t('activity_boosting')}</BodySSB>
343+
</View>
344+
);
345+
}
346+
347+
if (confirmed) {
348+
status = (
349+
<View testID="StatusConfirmed" style={styles.row}>
350+
<CheckCircleIcon style={styles.rowIcon} color="green" />
351+
<BodySSB color="green">{t('activity_confirmed')}</BodySSB>
352+
</View>
353+
);
354+
}
355+
356356
if (activityType === EActivityType.onchain && !exists) {
357357
status = (
358358
<View style={styles.row}>

src/screens/Activity/ListItem.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,7 @@ const OnchainListItem = ({
108108
const amount = isSend ? value + fee : value;
109109

110110
let description;
111-
if (confirmed) {
112-
// NOTE: for users with earlier versions use the timestamp
113-
description = getActivityItemDate(confirmTimestamp ?? timestamp);
114-
} else if (isBoosted) {
115-
description = t('activity_confirms_in_boosted', { feeRateDescription });
116-
icon = (
117-
<ThemedView testID="BoostingIcon" style={styles.icon} color="yellow16">
118-
<TimerIconAlt height={13} color="yellow" />
119-
</ThemedView>
120-
);
121-
} else if (feeRateDescription) {
111+
if (feeRateDescription) {
122112
description = t('activity_confirms_in', { feeRateDescription });
123113
} else {
124114
description = t('activity_low_fee');
@@ -141,6 +131,22 @@ const OnchainListItem = ({
141131
}
142132
}
143133

134+
if (isBoosted && !confirmed) {
135+
description = t('activity_confirms_in_boosted', { feeRateDescription });
136+
icon = (
137+
<ThemedView style={styles.icon} color="yellow16" testID="BoostingIcon">
138+
<TimerIconAlt height={13} color="yellow" />
139+
</ThemedView>
140+
);
141+
}
142+
143+
if (confirmed) {
144+
if (!transfer) {
145+
// NOTE: for users with earlier versions use the timestamp
146+
description = getActivityItemDate(confirmTimestamp ?? timestamp);
147+
}
148+
}
149+
144150
return (
145151
<ListItem
146152
title={title}

src/utils/wallet/transfer.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import lm, { ldk } from '@synonymdev/react-native-ldk';
99

1010
import { getCurrentWallet, getSelectedNetwork, refreshWallet } from '.';
1111
import { btcToSats } from '../conversion';
12+
import { getBoostedTransactionParents } from '../boost';
1213
import { getTransactions } from './electrum';
1314
import {
1415
ETransferStatus,
@@ -34,13 +35,29 @@ export const getTransferForTx = async (
3435
const transfers = currentWallet.transfers[selectedNetwork];
3536

3637
if (tx.type === EPaymentType.sent) {
37-
const transfersToSpending = transfers.filter(
38-
(t) => t.type === ETransferType.open,
39-
);
38+
const transfersToSpending = transfers.filter((t) => {
39+
return t.type === ETransferType.open;
40+
});
41+
4042
// check if the tx is a transfer to spending
41-
const transferToSpending = transfersToSpending.find(
42-
(t) => t.txId === tx.txid,
43-
);
43+
let transferToSpending = transfersToSpending.find((t) => {
44+
return t.txId === tx.txid;
45+
});
46+
47+
// check if the tx is a transfer that was boosted
48+
if (!transferToSpending) {
49+
const boostedParents = getBoostedTransactionParents({ txId: tx.txid });
50+
const isBoosted = boostedParents.length > 0;
51+
if (isBoosted) {
52+
transferToSpending = transfersToSpending.find((t) => {
53+
const boostedParent = boostedParents.find((txId) => {
54+
return t.txId === txId;
55+
});
56+
return t.txId === boostedParent;
57+
});
58+
}
59+
}
60+
4461
if (transferToSpending) {
4562
return transferToSpending;
4663
}

0 commit comments

Comments
 (0)