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(
|
fun WalletScreen(
|
||||||
vm : WalletViewModel,
|
vm : WalletViewModel,
|
||||||
pendingPaymentHash: MutableState<String?>,
|
pendingPaymentHash: MutableState<String?>,
|
||||||
pendingPaymentUri : MutableState<String?> // SESSION 09: deep link / intent URI
|
pendingPaymentUri : MutableState<String?>
|
||||||
) {
|
) {
|
||||||
val navController = rememberNavController()
|
val navController = rememberNavController()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -282,8 +282,9 @@ fun WalletScreen(
|
|||||||
composable(TabItem.Send.route) {
|
composable(TabItem.Send.route) {
|
||||||
SendScreen(
|
SendScreen(
|
||||||
vm = vm,
|
vm = vm,
|
||||||
onViewDetails = { paymentHash ->
|
onViewDetails = { checkingId ->
|
||||||
navController.navigate("payment_detail/$paymentHash") {
|
historyVm.refresh()
|
||||||
|
navController.navigate("payment_detail/$checkingId") {
|
||||||
launchSingleTop = true
|
launchSingleTop = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,8 +329,14 @@ fun WalletScreen(
|
|||||||
arguments = listOf(navArgument("checkingId") { type = NavType.StringType })
|
arguments = listOf(navArgument("checkingId") { type = NavType.StringType })
|
||||||
) { backStackEntry ->
|
) { backStackEntry ->
|
||||||
val checkingId = backStackEntry.arguments?.getString("checkingId") ?: ""
|
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) {
|
if (payment != null) {
|
||||||
PaymentDetailScreen(
|
PaymentDetailScreen(
|
||||||
payment = payment,
|
payment = payment,
|
||||||
|
|||||||
Reference in New Issue
Block a user