Skip to content

Commit d6b6799

Browse files
committed
Fix comments
1 parent 98e6727 commit d6b6799

File tree

2 files changed

+21
-31
lines changed

2 files changed

+21
-31
lines changed

app/src/main/java/to/bitkit/ui/settings/advanced/AddressViewerViewModel.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import to.bitkit.di.BgDispatcher
1818
import to.bitkit.models.AddressModel
1919
import to.bitkit.repositories.LightningRepo
2020
import to.bitkit.repositories.WalletRepo
21-
import to.bitkit.utils.Logger
2221
import javax.inject.Inject
2322

2423
@HiltViewModel
@@ -166,12 +165,8 @@ class AddressViewerViewModel @Inject constructor(
166165
}
167166
}
168167

169-
suspend fun getBalanceForAddress(address: String): Result<Long> = withContext(bgDispatcher) {
170-
return@withContext lightningRepo.getAddressBalance(address).map { it.toLong() }
171-
.onFailure { e ->
172-
Logger.error("Error getting balance for address $address", e)
173-
}
174-
}
168+
suspend fun getBalanceForAddress(address: String): Result<Long> =
169+
lightningRepo.getAddressBalance(address).map { it.toLong() }
175170
}
176171

177172
data class UiState(

app/src/main/java/to/bitkit/ui/settings/lightning/LightningConnectionsViewModel.kt

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -413,30 +413,25 @@ class LightningConnectionsViewModel @Inject constructor(
413413
}
414414

415415
fun fetchActivityTimestamp(channelId: String) {
416-
viewModelScope.launch(bgDispatcher) {
417-
runCatching {
418-
val activities = activityRepo.getActivities(
419-
filter = ActivityFilter.ONCHAIN,
420-
txType = PaymentType.SENT,
421-
tags = null,
422-
search = null,
423-
minDate = null,
424-
maxDate = null,
425-
limit = null,
426-
sortDirection = null
427-
).getOrNull() ?: emptyList()
428-
429-
val transferActivity = activities.firstOrNull { activity ->
430-
activity is Activity.Onchain &&
431-
activity.v1.isTransfer &&
432-
activity.v1.channelId == channelId
433-
} as? Activity.Onchain
434-
435-
_txTime.update { transferActivity?.v1?.confirmTimestamp ?: transferActivity?.v1?.timestamp }
436-
}.onFailure { e ->
437-
Logger.warn("fetchActivityTimestamp error for channelId: '$channelId'", e, context = TAG)
438-
_txTime.update { null }
439-
}
416+
viewModelScope.launch {
417+
val activities = activityRepo.getActivities(
418+
filter = ActivityFilter.ONCHAIN,
419+
txType = PaymentType.SENT,
420+
tags = null,
421+
search = null,
422+
minDate = null,
423+
maxDate = null,
424+
limit = null,
425+
sortDirection = null
426+
).getOrNull() ?: emptyList()
427+
428+
val transferActivity = activities.firstOrNull { activity ->
429+
activity is Activity.Onchain &&
430+
activity.v1.isTransfer &&
431+
activity.v1.channelId == channelId
432+
} as? Activity.Onchain
433+
434+
_txTime.update { transferActivity?.v1?.confirmTimestamp ?: transferActivity?.v1?.timestamp }
440435
}
441436
}
442437

0 commit comments

Comments
 (0)