@@ -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