Skip to content

Commit 2727791

Browse files
committed
feat: collect TO_SPENDING event
1 parent c2b9ce3 commit 2727791

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import com.synonym.bitkitcore.PaymentType
77
import com.synonym.bitkitcore.SortDirection
88
import kotlinx.coroutines.CoroutineDispatcher
99
import kotlinx.coroutines.delay
10-
import kotlinx.coroutines.flow.MutableStateFlow
11-
import kotlinx.coroutines.flow.asStateFlow
12-
import kotlinx.coroutines.flow.combine
1310
import kotlinx.coroutines.flow.first
11+
import kotlinx.coroutines.flow.map
1412
import kotlinx.coroutines.withContext
1513
import org.lightningdevkit.ldknode.PaymentDetails
1614
import to.bitkit.data.CacheStore
@@ -36,8 +34,7 @@ class ActivityRepo @Inject constructor(
3634

3735
var isSyncingLdkNodePayments = false
3836

39-
private val _pendingTransfers: MutableStateFlow<List<Activity.Onchain>> = MutableStateFlow(emptyList())
40-
val pendingTransfers = _pendingTransfers.asStateFlow()
37+
val inProgressTransfers = cacheStore.data.map { it.inProgressTransfers }
4138

4239
suspend fun syncActivities(): Result<Unit> = withContext(bgDispatcher) {
4340
Logger.debug("syncActivities called", context = TAG)

app/src/main/java/to/bitkit/ui/screens/wallets/HomeViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.update
1414
import kotlinx.coroutines.launch
1515
import kotlinx.datetime.Clock
1616
import to.bitkit.data.SettingsStore
17+
import to.bitkit.data.dto.TransferType
1718
import to.bitkit.models.Suggestion
1819
import to.bitkit.models.WidgetType
1920
import to.bitkit.models.toSuggestionOrNull
@@ -257,7 +258,8 @@ class HomeViewModel @Inject constructor(
257258
private fun createSuggestionsFlow() = combine(
258259
walletRepo.balanceState,
259260
settingsStore.data,
260-
) { balanceState, settings ->
261+
activityRepo.inProgressTransfers
262+
) { balanceState, settings, transfers ->
261263
val baseSuggestions = when {
262264
balanceState.totalLightningSats > 0uL -> { // With Lightning
263265
listOfNotNull(
@@ -275,7 +277,9 @@ class HomeViewModel @Inject constructor(
275277
balanceState.totalOnchainSats > 0uL -> { // Only on chain balance
276278
listOfNotNull(
277279
Suggestion.BACK_UP.takeIf { !settings.backupVerified },
278-
Suggestion.SPEND, // TODO Replace with LIGHTNING_SETTING_UP when the spending balance is confirming
280+
Suggestion.SPEND.takeIf {
281+
!transfers.any { it.type == TransferType.TO_SPENDING }
282+
} ?: Suggestion.LIGHTNING_SETTING_UP,
279283
Suggestion.SECURE.takeIf { !settings.isPinEnabled },
280284
Suggestion.BUY,
281285
Suggestion.SUPPORT,

0 commit comments

Comments
 (0)