Skip to content

Commit bfc497c

Browse files
committed
refactor: add activity.txType extension
1 parent 4e48d95 commit bfc497c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

app/src/main/java/to/bitkit/ext/Activities.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ fun Activity.rawId(): String = when (this) {
99
is Activity.Onchain -> v1.id
1010
}
1111

12+
fun Activity.txType(): PaymentType = when (this) {
13+
is Activity.Lightning -> v1.txType
14+
is Activity.Onchain -> v1.txType
15+
}
16+
1217
/**
1318
* Calculates the total value of an activity based on its type.
1419
*

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityIcon.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import to.bitkit.R
2727
import to.bitkit.ext.isBoosted
2828
import to.bitkit.ext.isFinished
2929
import to.bitkit.ext.isTransfer
30+
import to.bitkit.ext.txType
3031
import to.bitkit.ui.theme.AppThemeSurface
3132
import to.bitkit.ui.theme.Colors
3233

@@ -41,10 +42,7 @@ fun ActivityIcon(
4142
is Activity.Lightning -> activity.v1.status
4243
is Activity.Onchain -> null
4344
}
44-
val txType: PaymentType = when (activity) {
45-
is Activity.Lightning -> activity.v1.txType
46-
is Activity.Onchain -> activity.v1.txType
47-
}
45+
val txType: PaymentType = activity.txType()
4846
val arrowIcon = painterResource(if (txType == PaymentType.SENT) R.drawable.ic_sent else R.drawable.ic_received)
4947

5048
when {

app/src/main/java/to/bitkit/ui/screens/wallets/activity/components/ActivityRow.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import to.bitkit.ext.isSent
3131
import to.bitkit.ext.isTransfer
3232
import to.bitkit.ext.rawId
3333
import to.bitkit.ext.totalValue
34+
import to.bitkit.ext.txType
3435
import to.bitkit.models.PrimaryDisplay
3536
import to.bitkit.models.formatToModernDisplay
3637
import to.bitkit.ui.LocalCurrencies
@@ -64,10 +65,7 @@ fun ActivityRow(
6465
is Activity.Lightning -> item.v1.timestamp
6566
is Activity.Onchain -> item.v1.timestamp
6667
}
67-
val txType: PaymentType = when (item) {
68-
is Activity.Lightning -> item.v1.txType
69-
is Activity.Onchain -> item.v1.txType
70-
}
68+
val txType: PaymentType = item.txType()
7169
val isSent = item.isSent()
7270
val amountPrefix = if (isSent) "-" else "+"
7371
val confirmed: Boolean? = when (item) {

0 commit comments

Comments
 (0)