Skip to content

Commit 8ed0321

Browse files
committed
fix: don't display persisted payment events
1 parent 08d461c commit 8ed0321

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

app/src/main/java/to/bitkit/ui/ContentView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ fun ContentView(
183183

184184
val pendingTransaction = NewTransactionSheetDetails.load(context)
185185
if (pendingTransaction != null) {
186-
appViewModel.showNewTransactionSheet(pendingTransaction)
186+
appViewModel.showNewTransactionSheet(details = pendingTransaction, event = null)
187187
NewTransactionSheetDetails.clear(context)
188188
}
189189

@@ -329,7 +329,7 @@ fun ContentView(
329329
onComplete = { txSheet ->
330330
appViewModel.hideSheet()
331331
appViewModel.clearClipboardForAutoRead()
332-
txSheet?.let { appViewModel.showNewTransactionSheet(it) }
332+
txSheet?.let { appViewModel.showNewTransactionSheet(details = it, event = null) }
333333
}
334334
)
335335
}

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,15 @@ class AppViewModel @Inject constructor(
192192
ldkNodeEventBus.events.collect { event ->
193193
try {
194194
when (event) {
195-
is Event.PaymentReceived -> {
195+
is Event.PaymentReceived -> { //TODO COMMING FROM HERE
196196
handleTags(event)
197197
showNewTransactionSheet(
198198
NewTransactionSheetDetails(
199199
type = NewTransactionSheetType.LIGHTNING,
200200
direction = NewTransactionSheetDirection.RECEIVED,
201201
sats = (event.amountMsat / 1000u).toLong(),
202-
)
202+
),
203+
event = event
203204
)
204205
}
205206

@@ -214,7 +215,8 @@ class AppViewModel @Inject constructor(
214215
type = NewTransactionSheetType.LIGHTNING,
215216
direction = NewTransactionSheetDirection.RECEIVED,
216217
sats = (channel.inboundCapacityMsat / 1000u).toLong(),
217-
)
218+
),
219+
event = event
218220
)
219221
} else {
220222
toast(
@@ -240,7 +242,8 @@ class AppViewModel @Inject constructor(
240242
type = NewTransactionSheetType.LIGHTNING,
241243
direction = NewTransactionSheetDirection.SENT,
242244
sats = ((event.feePaidMsat ?: 0u) / 1000u).toLong(),
243-
)
245+
),
246+
event = event
244247
)
245248
}
246249

@@ -1202,10 +1205,27 @@ class AppViewModel @Inject constructor(
12021205
isNewTransactionSheetEnabled = enabled
12031206
}
12041207

1205-
fun showNewTransactionSheet(details: NewTransactionSheetDetails) {
1208+
fun showNewTransactionSheet(
1209+
details: NewTransactionSheetDetails,
1210+
event: Event?,
1211+
) = viewModelScope.launch {
12061212
if (!isNewTransactionSheetEnabled) {
12071213
Logger.debug("NewTransactionSheet display blocked by isNewTransactionSheetEnabled=false", context = TAG)
1208-
return
1214+
return@launch
1215+
}
1216+
1217+
if (event is Event.PaymentReceived) {
1218+
val activity = activityRepo.findActivityByPaymentId(
1219+
paymentHashOrTxId = event.paymentHash,
1220+
type = ActivityFilter.ALL,
1221+
txType = PaymentType.RECEIVED,
1222+
retry = false
1223+
).getOrNull()
1224+
1225+
if (activity != null) {
1226+
Logger.verbose("Activity already exists, skipping sheet", context = TAG)
1227+
return@launch
1228+
}
12091229
}
12101230

12111231
newTransaction = details

0 commit comments

Comments
 (0)