fix: call historyVm.refresh() so that details load when received
This commit is contained in:
@@ -78,7 +78,7 @@ private const val ROUTE_PAYMENT_DETAIL = "payment_detail/{checkingId}"
|
||||
fun WalletScreen(
|
||||
vm : WalletViewModel,
|
||||
pendingPaymentHash: MutableState<String?>,
|
||||
pendingPaymentUri : MutableState<String?> // SESSION 09: deep link / intent URI
|
||||
pendingPaymentUri : MutableState<String?>
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
val context = LocalContext.current
|
||||
@@ -282,8 +282,9 @@ fun WalletScreen(
|
||||
composable(TabItem.Send.route) {
|
||||
SendScreen(
|
||||
vm = vm,
|
||||
onViewDetails = { paymentHash ->
|
||||
navController.navigate("payment_detail/$paymentHash") {
|
||||
onViewDetails = { checkingId ->
|
||||
historyVm.refresh()
|
||||
navController.navigate("payment_detail/$checkingId") {
|
||||
launchSingleTop = true
|
||||
}
|
||||
}
|
||||
@@ -328,8 +329,14 @@ fun WalletScreen(
|
||||
arguments = listOf(navArgument("checkingId") { type = NavType.StringType })
|
||||
) { backStackEntry ->
|
||||
val checkingId = backStackEntry.arguments?.getString("checkingId") ?: ""
|
||||
val payment = historyVm.findPayment(checkingId)
|
||||
|
||||
val historyState by historyVm.filteredState.collectAsStateWithLifecycle()
|
||||
val fallbackState by historyVm.state.collectAsStateWithLifecycle()
|
||||
val payment = remember(historyState, fallbackState, checkingId) {
|
||||
(historyState as? HistoryState.Success)
|
||||
?.payments?.firstOrNull { it.checkingId == checkingId }
|
||||
?: (fallbackState as? HistoryState.Success)
|
||||
?.payments?.firstOrNull { it.checkingId == checkingId }
|
||||
}
|
||||
if (payment != null) {
|
||||
PaymentDetailScreen(
|
||||
payment = payment,
|
||||
|
||||
Reference in New Issue
Block a user