Skip to content

Commit 9f7a62f

Browse files
committed
chore: review
1 parent b955a4e commit 9f7a62f

8 files changed

Lines changed: 224 additions & 259 deletions

File tree

app/src/androidTest/java/to/bitkit/ui/screens/wallets/send/SendAmountContentTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class SendAmountContentTest {
4646
fun whenNodeNotRunning_shouldShowSyncView() {
4747
composeTestRule.setContent {
4848
SendAmountContent(
49-
nodeLifecycleState = nodeLifecycleState,
49+
nodeLifecycleState = NodeLifecycleState.Initializing,
5050
uiState = uiState,
5151
amountInputViewModel = previewAmountInputViewModel(),
5252
)

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

Lines changed: 108 additions & 128 deletions
Large diffs are not rendered by default.

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class LightningRepo @Inject constructor(
346346
lightningService.sync()
347347
refreshChannelCache()
348348
syncState()
349-
if (syncPending.get()) delay(SYNC_LOOP_DEBOUNCE_MS)
349+
if (syncPending.get()) delay(MS_SYNC_LOOP_DEBOUNCE)
350350
} while (syncPending.getAndSet(false))
351351
} finally {
352352
_lightningState.update { it.copy(isSyncingWallet = false) }
@@ -410,7 +410,7 @@ class LightningRepo @Inject constructor(
410410
}
411411

412412
val channelName = channel.inboundScidAlias?.toString()
413-
?: (channel.channelId.take(CHANNEL_ID_PREVIEW_LENGTH) + "")
413+
?: (channel.channelId.take(LENGTH_CHANNEL_ID_PREVIEW) + "")
414414

415415
val closedAt = (System.currentTimeMillis() / 1000L).toULong()
416416

@@ -922,7 +922,9 @@ class LightningRepo @Inject constructor(
922922
return@runCatching replacementTxId
923923
}.onFailure {
924924
Logger.error(
925-
"bumpFeeByRbf error originalTxId: $originalTxId, satsPerVByte: $satsPerVByte", it, context = TAG,
925+
"bumpFeeByRbf error originalTxId: $originalTxId, satsPerVByte: $satsPerVByte",
926+
it,
927+
context = TAG,
926928
)
927929
}
928930
}
@@ -959,25 +961,25 @@ class LightningRepo @Inject constructor(
959961
}
960962

961963
suspend fun estimateRoutingFees(bolt11: String): Result<ULong> = executeWhenNodeRunning("estimateRoutingFees") {
962-
Logger.info("Estimating routing fees for bolt11: $bolt11")
964+
Logger.info("Estimating routing fees for bolt11: $bolt11", context = TAG)
963965
lightningService.estimateRoutingFees(bolt11)
964966
.onSuccess {
965967
Logger.info("Routing fees estimated: $it", context = TAG)
966968
}
967969
.onFailure {
968-
Logger.error("Routing fees estimation failed", it, context = TAG)
970+
Logger.error("estimateRoutingFees error", it, context = TAG)
969971
}
970972
}
971973

972974
suspend fun estimateRoutingFeesForAmount(bolt11: String, amountSats: ULong): Result<ULong> =
973975
executeWhenNodeRunning("estimateRoutingFeesForAmount") {
974-
Logger.info("Estimating routing fees for amount: $amountSats")
976+
Logger.info("Estimating routing fees for amount: $amountSats", context = TAG)
975977
lightningService.estimateRoutingFeesForAmount(bolt11, amountSats)
976978
.onSuccess {
977979
Logger.info("Routing fees estimated: $it", context = TAG)
978980
}
979981
.onFailure {
980-
Logger.error("Routing fees estimation failed", it, context = TAG)
982+
Logger.error("estimateRoutingFees error", it, context = TAG)
981983
}
982984
}
983985

@@ -1006,8 +1008,8 @@ class LightningRepo @Inject constructor(
10061008

10071009
companion object {
10081010
private const val TAG = "LightningRepo"
1009-
private const val CHANNEL_ID_PREVIEW_LENGTH = 10
1010-
private const val SYNC_LOOP_DEBOUNCE_MS = 500L
1011+
private const val LENGTH_CHANNEL_ID_PREVIEW = 10
1012+
private const val MS_SYNC_LOOP_DEBOUNCE = 500L
10111013
}
10121014
}
10131015

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ActivityListViewModel @Inject constructor(
8989
) { debouncedSearch, filtersWithoutSearch, _ ->
9090
fetchFilteredActivities(filtersWithoutSearch.copy(searchText = debouncedSearch))
9191
}.collect {
92-
_filteredActivities.value = it
92+
_filteredActivities.update { it }
9393
}
9494
}
9595

@@ -115,8 +115,8 @@ class ActivityListViewModel @Inject constructor(
115115
search = filters.searchText.takeIf { it.isNotEmpty() },
116116
minDate = filters.startDate?.let { it / 1000 }?.toULong(),
117117
maxDate = filters.endDate?.let { it / 1000 }?.toULong(),
118-
).getOrElse { e ->
119-
Logger.error("Failed to filter activities", e)
118+
).getOrElse {
119+
Logger.error("Failed to filter activities", it, context = TAG)
120120
return null
121121
}
122122

@@ -132,9 +132,9 @@ class ActivityListViewModel @Inject constructor(
132132
private suspend fun filterOutReplacedSentTransactions(activities: List<Activity>): List<Activity> {
133133
val txIdsInBoostTxIds = activityRepo.getTxIdsInBoostTxIds()
134134

135-
return activities.filter { activity ->
136-
if (activity is Activity.Onchain) {
137-
val onchain = activity.v1
135+
return activities.filter {
136+
if (it is Activity.Onchain) {
137+
val onchain = it.v1
138138
if (!onchain.doesExist &&
139139
onchain.txType == PaymentType.SENT &&
140140
txIdsInBoostTxIds.contains(onchain.txId)
@@ -180,6 +180,7 @@ class ActivityListViewModel @Inject constructor(
180180
): StateFlow<T> = stateIn(viewModelScope, started, initialValue)
181181

182182
companion object {
183+
private const val TAG = "ActivityListViewModel"
183184
private const val SIZE_LATEST = 3
184185
private const val MS_TIMEOUT_SUB = 5000L
185186
}

0 commit comments

Comments
 (0)