Skip to content

Commit d4c3aef

Browse files
committed
fix: don’t block boost success on sync
1 parent cfbcf20 commit d4c3aef

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ class LightningRepo @Inject constructor(
334334
Result.success(Unit)
335335
}
336336

337+
fun syncAsync() = scope.launch {
338+
sync().onFailure { error ->
339+
Logger.warn("Sync failed", e = error, context = TAG)
340+
}
341+
}
342+
337343
/** Clear pending sync flag. Called when manual pull-to-refresh takes priority. */
338344
fun clearPendingSync() {
339345
syncPending.set(false)

app/src/main/java/to/bitkit/ui/sheets/BoostTransactionViewModel.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,20 +209,16 @@ class BoostTransactionViewModel @Inject constructor(
209209

210210
private suspend fun handleBoostSuccess(newTxId: Txid, isRBF: Boolean) {
211211
Logger.debug("Boost successful. newTxId: $newTxId", context = TAG)
212-
updateActivity(newTxId = newTxId, isRBF = isRBF).fold(
213-
onSuccess = {
214-
lightningRepo.sync()
215-
activityRepo.syncActivities()
216-
_uiState.update { it.copy(boosting = false) }
217-
setBoostTransactionEffect(BoostTransactionEffects.OnBoostSuccess)
218-
},
219-
onFailure = { error ->
220-
// Boost succeeded but activity update failed - still consider it successful
212+
updateActivity(newTxId = newTxId, isRBF = isRBF)
213+
.onFailure { error ->
221214
Logger.warn("Boost successful but activity update failed", e = error, context = TAG)
222-
_uiState.update { it.copy(boosting = false) }
223-
setBoostTransactionEffect(BoostTransactionEffects.OnBoostSuccess)
224215
}
225-
)
216+
217+
_uiState.update { it.copy(boosting = false) }
218+
setBoostTransactionEffect(BoostTransactionEffects.OnBoostSuccess)
219+
220+
// Fire-and-forget sync to keep UI responsive even if LDK sync hangs.
221+
lightningRepo.syncAsync()
226222
}
227223

228224
fun onChangeAmount(increase: Boolean) {

0 commit comments

Comments
 (0)