Skip to content

Commit 2342045

Browse files
committed
Fix Claude comments
1 parent 7093e21 commit 2342045

3 files changed

Lines changed: 17 additions & 27 deletions

File tree

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ class SweepRepo @Inject constructor(
100100

101101
suspend fun getFeeRates(): Result<FeeRates> = coreService.blocktank.getFees()
102102

103+
suspend fun hasSweepableFunds(): Result<Boolean> = checkSweepableBalances().map { balances ->
104+
val hasFunds = balances.totalBalance > 0u
105+
if (hasFunds) {
106+
Logger.info("Found ${balances.totalBalance} sats to sweep", context = TAG)
107+
} else {
108+
Logger.debug("No sweepable funds found", context = TAG)
109+
}
110+
hasFunds
111+
}
112+
103113
companion object {
104114
private const val TAG = "SweepRepo"
105115
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,8 @@ class AppViewModel @Inject constructor(
457457

458458
fun checkForSweepableFunds() {
459459
viewModelScope.launch(bgDispatcher) {
460-
val hasSweepableFunds = SweepViewModel.checkForSweepableFundsAfterMigration(sweepRepo)
461-
if (hasSweepableFunds) {
462-
showSheet(Sheet.SweepPrompt)
463-
}
460+
sweepRepo.hasSweepableFunds()
461+
.onSuccess { hasFunds -> if (hasFunds) showSheet(Sheet.SweepPrompt) }
464462
}
465463
}
466464

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class SweepViewModel @Inject constructor(
4040
}
4141
},
4242
onFailure = { error ->
43-
Logger.error("Failed to check sweepable balance", error, TAG)
43+
Logger.error("Failed to check sweepable balance", error, context = TAG)
4444
_uiState.update { it.copy(checkState = CheckState.Error(error.message ?: "Unknown error")) }
4545
}
4646
)
@@ -65,7 +65,7 @@ class SweepViewModel @Inject constructor(
6565
_uiState.update { it.copy(destinationAddress = address) }
6666
},
6767
onFailure = { error ->
68-
Logger.error("Failed to get destination address", error, TAG)
68+
Logger.error("Failed to get destination address", error, context = TAG)
6969
val errorMsg = "Failed to get destination address"
7070
_uiState.update {
7171
it.copy(sweepState = SweepState.Error(errorMsg), errorMessage = errorMsg)
@@ -90,7 +90,7 @@ class SweepViewModel @Inject constructor(
9090
}
9191
},
9292
onFailure = { error ->
93-
Logger.error("Failed to prepare sweep", error, TAG)
93+
Logger.error("Failed to prepare sweep", error, context = TAG)
9494
_uiState.update {
9595
it.copy(
9696
sweepState = SweepState.Error(error.message ?: "Unknown error"),
@@ -120,7 +120,7 @@ class SweepViewModel @Inject constructor(
120120
}
121121
},
122122
onFailure = { error ->
123-
Logger.error("Failed to broadcast sweep", error, TAG)
123+
Logger.error("Failed to broadcast sweep", error, context = TAG)
124124
_uiState.update {
125125
it.copy(
126126
sweepState = SweepState.Error(error.message ?: "Unknown error"),
@@ -153,7 +153,7 @@ class SweepViewModel @Inject constructor(
153153
}
154154
},
155155
onFailure = { error ->
156-
Logger.error("Failed to load fee estimates", error, TAG)
156+
Logger.error("Failed to load fee estimates", error, context = TAG)
157157
_uiState.update { it.copy(errorMessage = error.message) }
158158
}
159159
)
@@ -165,24 +165,6 @@ class SweepViewModel @Inject constructor(
165165

166166
companion object {
167167
private const val TAG = "SweepViewModel"
168-
169-
suspend fun checkForSweepableFundsAfterMigration(sweepRepo: SweepRepo): Boolean {
170-
return sweepRepo.checkSweepableBalances().fold(
171-
onSuccess = { balances ->
172-
if (balances.totalBalance > 0u) {
173-
Logger.info("Found ${balances.totalBalance} sats to sweep after migration", context = TAG)
174-
true
175-
} else {
176-
Logger.debug("No sweepable funds found after migration", context = TAG)
177-
false
178-
}
179-
},
180-
onFailure = { error ->
181-
Logger.error("Failed to check sweepable funds after migration", error, TAG)
182-
false
183-
}
184-
)
185-
}
186168
}
187169
}
188170

0 commit comments

Comments
 (0)