Skip to content

Commit 5c46459

Browse files
committed
feat: handle self-send
1 parent 74de74c commit 5c46459

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fun Activity.totalValue() = when(this) {
2828
}
2929

3030
fun Activity.canBeBoosted() = when (this) {
31-
is Activity.Onchain -> !v1.confirmed && v1.doesExist && !v1.isBoosted && !v1.isTransfer
31+
is Activity.Onchain -> !v1.confirmed && v1.doesExist && !v1.isBoosted && !v1.isTransfer && v1.value > 0uL
3232
else -> false
3333
}
3434

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ private fun ActivityDetailContent(
206206
is Activity.Lightning -> item.v1.fee
207207
is Activity.Onchain -> item.v1.fee
208208
}
209+
val isSelfSend = isSent && paymentValue == 0uL
209210

210211
Column(
211212
modifier = Modifier
@@ -226,7 +227,7 @@ private fun ActivityDetailContent(
226227
forceShowBalance = true,
227228
modifier = Modifier.weight(1f)
228229
)
229-
ActivityIcon(activity = item, size = 48.dp)
230+
ActivityIcon(activity = item, size = 48.dp) //TODO Display the user avatar when selfsend
230231
}
231232

232233
Spacer(modifier = Modifier.height(16.dp))
@@ -289,7 +290,11 @@ private fun ActivityDetailContent(
289290
) {
290291
Column(modifier = Modifier.weight(1f)) {
291292
Caption13Up(
292-
text = stringResource(R.string.wallet__activity_payment),
293+
text = if (isSelfSend) {
294+
"Sent to myself" //TODO translation
295+
} else {
296+
stringResource(R.string.wallet__activity_payment)
297+
},
293298
color = Colors.White64,
294299
modifier = Modifier.padding(top = 16.dp, bottom = 8.dp)
295300
)
@@ -436,7 +441,13 @@ private fun ActivityDetailContent(
436441
modifier = Modifier.fillMaxWidth()
437442
) {
438443
PrimaryButton(
439-
text = stringResource(if (item.isBoosted()) R.string.wallet__activity_boosted else R.string.wallet__activity_boost),
444+
text = stringResource(
445+
if (item.isBoosted()) {
446+
R.string.wallet__activity_boosted
447+
} else {
448+
R.string.wallet__activity_boost
449+
}
450+
),
440451
size = ButtonSize.Small,
441452
onClick = onClickBoost,
442453
enabled = item.canBeBoosted(),

app/src/main/java/to/bitkit/viewmodels/ActivityDetailViewModel.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class ActivityDetailViewModel @Inject constructor(
2424
@BgDispatcher private val bgDispatcher: CoroutineDispatcher,
2525
private val addressChecker: AddressChecker,
2626
private val coreService: CoreService,
27-
private val lightningRepo: LightningRepo,
2827
private val settingsStore: SettingsStore,
2928
) : ViewModel() {
3029
private val _txDetails = MutableStateFlow<TxDetails?>(null)

0 commit comments

Comments
 (0)