Skip to content

Commit eb9efb5

Browse files
committed
fix: bill exit when grabbed should pop
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 97101a6 commit eb9efb5

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

app/src/main/java/com/getcode/domain/CashLinkManager.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class CashLinkManager @Inject constructor(
3535
onTimeout: () -> Unit,
3636
onError: (Throwable) -> Unit
3737
) {
38-
// this should not be in the view model
3938
sendTransactionDisposable?.dispose()
4039
val payload = sendTransactionRepository.init(amount, organizer, owner)
4140
sendTransactionDisposable =

app/src/main/java/com/getcode/view/main/home/HomeViewModel.kt

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ class HomeViewModel @Inject constructor(
429429
vibrator.vibrate()
430430

431431
viewModelScope.launch {
432-
balanceController.fetchBalanceSuspend()
433432
client.fetchLimits(true).subscribe({}, ErrorUtils::handleError)
434433
}
435434
},
@@ -447,6 +446,7 @@ class HomeViewModel @Inject constructor(
447446
}
448447

449448
private fun presentSend(data: List<Byte>, bill: Bill, isVibrate: Boolean = false) {
449+
println("present send")
450450
if (bill.didReceive) {
451451
uiFlow.update {
452452
val billState = it.billState
@@ -499,36 +499,40 @@ class HomeViewModel @Inject constructor(
499499
cashLinkManager.cancelSend()
500500
BottomBarManager.clearByType(BottomBarManager.BottomBarMessageType.REMOTE_SEND)
501501

502-
val shown = showToastIfNeeded(style)
502+
viewModelScope.launch {
503+
val shown = showToastIfNeeded(style)
504+
withContext(Dispatchers.Main) {
505+
uiFlow.update {
506+
it.copy(
507+
presentationStyle = style,
508+
)
509+
}
503510

504-
uiFlow.update {
505-
it.copy(
506-
presentationStyle = style,
507-
billState = it.billState.copy(
508-
bill = null,
509-
valuation = null,
510-
primaryAction = null,
511-
secondaryAction = null,
512-
)
513-
)
514-
}
511+
uiFlow.update {
512+
it.copy(
513+
billState = it.billState.copy(
514+
bill = null,
515+
valuation = null,
516+
primaryAction = null,
517+
secondaryAction = null,
518+
)
519+
)
520+
}
521+
}
515522

516-
viewModelScope.launch {
517523
historyController.fetchChats()
518524
balanceController.fetchBalanceSuspend()
519525

520-
if (shown) {
521-
delay(300)
522-
}
523-
524526
if (shown) {
525527
delay(5.seconds.inWholeMilliseconds)
526528
}
529+
withContext(Dispatchers.Main) {
527530
uiFlow.update {
528531
it.copy(
529532
billState = it.billState.copy(showToast = false)
530533
)
531534
}
535+
}
532536
}
533537
}
534538

0 commit comments

Comments
 (0)