Skip to content

Commit d970b5b

Browse files
committed
fix: implement search by payment id
1 parent eabf0ad commit d970b5b

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

app/src/main/java/to/bitkit/fcm/WakeNodeWorker.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class WakeNodeWorker @AssistedInject constructor(
118118
NewTransactionSheetDetails(
119119
type = NewTransactionSheetType.LIGHTNING,
120120
direction = NewTransactionSheetDirection.RECEIVED,
121+
paymentHashOrTxId = event.paymentHash,
121122
sats = sats.toLong(),
122123
)
123124
)

app/src/main/java/to/bitkit/models/NewTransactionSheetDetails.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ private const val APP_PREFS = "bitkit_prefs"
1515
data class NewTransactionSheetDetails(
1616
val type: NewTransactionSheetType,
1717
val direction: NewTransactionSheetDirection,
18+
val paymentHashOrTxId: String? = null,
1819
val sats: Long,
1920
) {
2021
companion object {

app/src/main/java/to/bitkit/ui/sheets/NewTransactionSheet.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ fun NewTransactionSheetView(
170170
SecondaryButton(
171171
text = stringResource(R.string.wallet__send_details),
172172
onClick = onDetailClick,
173+
enabled = details.paymentHashOrTxId != null,
173174
modifier = Modifier
174175
.weight(1f)
175176
.testTag("details_button")

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class AppViewModel @Inject constructor(
198198
NewTransactionSheetDetails(
199199
type = NewTransactionSheetType.LIGHTNING,
200200
direction = NewTransactionSheetDirection.RECEIVED,
201+
paymentHashOrTxId = event.paymentHash,
201202
sats = (event.amountMsat / 1000u).toLong(),
202203
),
203204
event = event
@@ -241,6 +242,7 @@ class AppViewModel @Inject constructor(
241242
NewTransactionSheetDetails(
242243
type = NewTransactionSheetType.LIGHTNING,
243244
direction = NewTransactionSheetDirection.SENT,
245+
paymentHashOrTxId = event.paymentHash,
244246
sats = ((event.feePaidMsat ?: 0u) / 1000u).toLong(),
245247
),
246248
event = event
@@ -937,6 +939,7 @@ class AppViewModel @Inject constructor(
937939
NewTransactionSheetDetails(
938940
type = NewTransactionSheetType.ONCHAIN,
939941
direction = NewTransactionSheetDirection.SENT,
942+
paymentHashOrTxId = txId,
940943
sats = amount.toLong(),
941944
)
942945
)
@@ -1028,19 +1031,22 @@ class AppViewModel @Inject constructor(
10281031
}
10291032

10301033
fun onClickActivityDetail() {
1031-
val filter = newTransaction.type.toActivityFilter()
1032-
val paymentType = newTransaction.direction.toTxType()
1034+
val activityType = newTransaction.type.toActivityFilter()
1035+
val txType = newTransaction.direction.toTxType()
1036+
val paymentHashOrTxId = newTransaction.paymentHashOrTxId ?: return
10331037

10341038
viewModelScope.launch(bgDispatcher) {
1035-
val activity = coreService.activity.get(filter = filter, txType = paymentType, limit = 1u).firstOrNull()
1036-
1037-
if (activity == null) {
1039+
activityRepo.findActivityByPaymentId(
1040+
paymentHashOrTxId = paymentHashOrTxId,
1041+
type = activityType,
1042+
txType = txType,
1043+
retry = true
1044+
).onSuccess { activity ->
1045+
val nextRoute = Routes.ActivityDetail(activity.rawId())
1046+
mainScreenEffect(MainScreenEffect.Navigate(nextRoute))
1047+
}.onFailure {
10381048
Logger.error(msg = "Activity not found", context = TAG)
1039-
return@launch
10401049
}
1041-
1042-
val nextRoute = Routes.ActivityDetail(activity.rawId())
1043-
mainScreenEffect(MainScreenEffect.Navigate(nextRoute))
10441050
}
10451051
}
10461052

@@ -1201,9 +1207,10 @@ class AppViewModel @Inject constructor(
12011207

12021208
var newTransaction by mutableStateOf(
12031209
NewTransactionSheetDetails(
1204-
NewTransactionSheetType.LIGHTNING,
1205-
NewTransactionSheetDirection.RECEIVED,
1206-
0
1210+
type = NewTransactionSheetType.LIGHTNING,
1211+
direction = NewTransactionSheetDirection.RECEIVED,
1212+
paymentHashOrTxId = null,
1213+
sats = 0
12071214
)
12081215
)
12091216

0 commit comments

Comments
 (0)