Skip to content

Commit 552cccb

Browse files
committed
refactor: call addTagsToTransaction
1 parent e9c2b3f commit 552cccb

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

app/src/main/java/to/bitkit/repositories/ActivityRepo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class ActivityRepo @Inject constructor(
451451
suspend fun addTagsToTransaction(
452452
paymentHashOrTxId: String,
453453
type: ActivityFilter,
454-
txType: PaymentType,
454+
txType: PaymentType?,
455455
tags: List<String>,
456456
): Result<Unit> = withContext(bgDispatcher) {
457457
if (tags.isEmpty()) return@withContext Result.failure(IllegalArgumentException("No tags selected"))
@@ -460,7 +460,7 @@ class ActivityRepo @Inject constructor(
460460
type = type,
461461
txType = txType
462462
).onSuccess { activity ->
463-
return@withContext addTagsToActivity(activity.rawId(), tags = tags)
463+
addTagsToActivity(activity.rawId(), tags = tags)
464464
}.onFailure { e ->
465465
return@withContext Result.failure(e)
466466
}.map { Unit }

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import kotlinx.coroutines.flow.debounce
1515
import kotlinx.coroutines.launch
1616
import kotlinx.coroutines.withContext
1717
import to.bitkit.di.BgDispatcher
18-
import to.bitkit.ext.rawId
1918
import to.bitkit.repositories.ActivityRepo
2019
import to.bitkit.repositories.WalletRepo
2120
import to.bitkit.services.CoreService
@@ -250,17 +249,13 @@ class ActivityListViewModel @Inject constructor(
250249
viewModelScope.launch {
251250
walletRepo.getAllInvoiceTags().onSuccess { invoiceTags ->
252251
invoiceTags.forEach { tagEntity ->
253-
activityRepo.findActivityByPaymentId(
252+
activityRepo.addTagsToTransaction(
254253
paymentHashOrTxId = tagEntity.paymentHash,
255254
type = ActivityFilter.ALL,
256-
txType = null
257-
).onSuccess { activity ->
258-
activityRepo.addTagsToActivity(
259-
activityId = activity.rawId(),
260-
tags = tagEntity.tags
261-
).onSuccess {
262-
walletRepo.deleteInvoice(tagEntity.paymentHash)
263-
}
255+
txType = null,
256+
tags = tagEntity.tags
257+
).onSuccess {
258+
walletRepo.deleteInvoice(tagEntity.paymentHash)
264259
}
265260
}
266261
}

0 commit comments

Comments
 (0)