Skip to content

Commit b8d111d

Browse files
committed
fix: improve scan -> presentation times
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 62ec471 commit b8d111d

4 files changed

Lines changed: 24 additions & 31 deletions

File tree

apps/flipcash/features/scanner/src/main/kotlin/com/flipcash/app/scanner/internal/bills/BillContainerView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ internal fun BillContainer(
120120
.fillMaxSize()
121121
.then(modifier)
122122
) {
123+
val availableUpdate by LocalAppUpdater.current.availableUpdate.collectAsStateWithLifecycle()
124+
123125
when {
124126
LocalBiometricsState.current.isAwaitingAuthentication -> {
125127
// waiting for result
126128
}
127129

128-
LocalAppUpdater.current.availableUpdate.value != null -> {
130+
availableUpdate != null -> {
129131
// waiting for update
130132
}
131133

apps/flipcash/shared/session/src/main/kotlin/com/flipcash/app/session/internal/RealSessionController.kt

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -814,12 +814,14 @@ class RealSessionController @Inject constructor(
814814
val grabTime = grabStart?.let {
815815
Clock.System.now().toEpochMilliseconds() - it
816816
}
817-
analytics.transfer(AnalyticsEvent.GrabBill, amount, grabTime = grabTime)
818-
BottomBarManager.clear()
819-
toastController.enqueue(amount, isDeposit = true)
817+
820818
showBill(
821819
bill = Bill.Cash(amount = amount, token = token, didReceive = true),
822820
)
821+
822+
analytics.transfer(AnalyticsEvent.GrabBill, amount, grabTime = grabTime)
823+
BottomBarManager.clear()
824+
toastController.enqueue(amount, isDeposit = true)
823825
checkPendingItemsInFeed()
824826
bringActivityFeedCurrent()
825827
},
@@ -839,21 +841,6 @@ class RealSessionController @Inject constructor(
839841
private fun presentBillToUser(data: List<Byte>, bill: Bill) {
840842
if (billController.state.value.bill != null) return
841843

842-
if (bill.didReceive) {
843-
billController.update {
844-
it.copy(
845-
valuation = PaymentValuation(bill.amount.nativeAmount),
846-
)
847-
}
848-
849-
vibrator.vibrate()
850-
}
851-
852-
val style: BillDeterminationResult =
853-
if (bill.didReceive) Grabbed else PutInWallet
854-
855-
_state.update { it.copy(billResult = style) }
856-
857844
billController.update {
858845
it.copy(
859846
bill = Bill.Cash(
@@ -867,15 +854,14 @@ class RealSessionController @Inject constructor(
867854
)
868855
}
869856

870-
if (style is BillDeterminationResult.ActedUpon) {
871-
// analytics.billShown(
872-
// bill.amountFloored.kin,
873-
// bill.amountFloored.rate.currency,
874-
// when (style) {
875-
// PresentationStyle.Pop -> CodeAnalyticsManager.BillPresentationStyle.Pop
876-
// PresentationStyle.Slide -> CodeAnalyticsManager.BillPresentationStyle.Slide
877-
// }
878-
// )
857+
val style: BillDeterminationResult =
858+
if (bill.didReceive) Grabbed else PutInWallet
859+
860+
_state.update { it.copy(billResult = style) }
861+
862+
if (bill.didReceive) {
863+
// shorter punch than standard
864+
vibrator.vibrate(duration = 50)
879865
}
880866
}
881867

services/opencode/src/main/kotlin/com/getcode/opencode/controllers/TokenController.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class TokenController @Inject constructor(
126126

127127
cluster.filterNotNull()
128128
.flatMapLatest { networkObserver.state }
129+
.distinctUntilChanged()
129130
.filter { it.connected }
130131
.onEach {
131132
trace(
@@ -579,7 +580,9 @@ class TokenController @Inject constructor(
579580
_state.update { it.copy(balances = it.balances + (token.address to newBalance)) }
580581
}
581582

582-
updateTokenAccount(token.address)
583+
scope.launch(Dispatchers.IO) {
584+
updateTokenAccount(token.address)
585+
}
583586
}
584587

585588
private fun streamReserveStates() {

services/opencode/src/main/kotlin/com/getcode/opencode/managers/BillTransactionManager.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class BillTransactionManager @Inject constructor(
7474

7575
giveTransactor = transactor
7676

77-
presentBillForGive(onTimeout)
7877
present(transactor.data)
78+
presentBillForGive(onTimeout)
7979

8080
transactor.start()
8181
.onSuccess {
@@ -136,7 +136,9 @@ class BillTransactionManager @Inject constructor(
136136
)
137137
onGrabbed(token, amount)
138138
tokenController.add(token, amount)
139-
transactionController.updateLimits(owner, force = true)
139+
sharedScope.launch {
140+
transactionController.updateLimits(owner, force = true)
141+
}
140142
}.onFailure {
141143
onError(it)
142144
transactor.dispose()

0 commit comments

Comments
 (0)