NTP-7745 | fix for mandate actions and exec polling (#13088)

This commit is contained in:
Shaurya Rehan
2024-10-15 01:14:53 +05:30
committed by GitHub
parent 76e2cf13b7
commit 2f387c71eb
5 changed files with 31 additions and 32 deletions

View File

@@ -222,7 +222,10 @@ constructor(
}
MandateResponseState.PENDING.name -> {
// Start poll for mandate status
initiatePollForMandateExecution(liteMandateInfo = upiLiteMandateInfo)
val updatedLiteMandateInfo = getCachedMandateInfo()
updatedLiteMandateInfo?.let {
initiatePollForMandateExecution(liteMandateInfo = updatedLiteMandateInfo)
}
}
else -> {
// Failed case, check if CL needs to be synced?

View File

@@ -4325,14 +4325,7 @@ constructor(
)
}
MandateResponseState.PENDING.name -> {
refreshScreenContent()
updateBottomSheetUiState(
showBottomSheet = true,
bottomSheetStateChange = false,
bottomSheetUiState = UpiLiteBottomSheetType.AutoTopUpSetupInProgressBottomSheet
)
updateUiState(uiState = UpiLiteUiState.MAIN_SCREEN)
naviPayAnalytics.onAutoTopUpInProgressBottomSheetLanded(
mandateStatus = MandateResponseState.PENDING.name
)
@@ -4346,13 +4339,19 @@ constructor(
)
)
updateBottomSheetUiState(
showBottomSheet = true,
bottomSheetStateChange = false,
bottomSheetUiState = UpiLiteBottomSheetType.AutoTopUpSetupInProgressBottomSheet
)
// start status polling
startStatusPollingForNonTerminalMandateStatus()
}
else -> {
// creation failed, delete cached mandate info
deleteLiteMandateInfo()
refreshScreenContent()
updateUiState(uiState = UpiLiteUiState.MAIN_SCREEN)
updateBottomSheetUiState(
showBottomSheet = true,
bottomSheetStateChange = true,
@@ -4876,7 +4875,7 @@ constructor(
)
if (!revokeMandateAPIResponse.isSuccessWithData()) {
refreshScreenContent()
updateUiState(uiState = UpiLiteUiState.MAIN_SCREEN)
updateBottomSheetUiState(
showBottomSheet = true,
bottomSheetUiState = UpiLiteBottomSheetType.AutoTopUpDeletionFailedBottomSheet,

View File

@@ -29,7 +29,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Scaffold
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.SheetState
import androidx.compose.material3.SheetValue
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@@ -38,7 +37,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
@@ -233,17 +231,6 @@ fun MandateDetailScreenOfActiveOrCompletedCategory(
}
}
LaunchedEffect(Unit) {
snapshotFlow { bottomSheetState.currentValue }
.collect {
if (it == SheetValue.Hidden) {
mandateDetailOfActiveOrCompletedCategoryViewModel.updateBottomSheetUIState(
showBottomSheet = false
)
}
}
}
LaunchedEffect(Unit) {
mandateDetailOfActiveOrCompletedCategoryViewModel.navigateToNextScreen.collect {
mandateDetailOfActiveOrCompletedCategoryViewModel.updateSnackBarState(
@@ -457,6 +444,7 @@ fun MandateDetailScreenOfActiveOrCompletedCategory(
val clipboardManager = LocalClipboardManager.current
// Todo: Check back press on loading bottom-sheet
when (uiState) {
is MandateDetailUIStateOfActiveOrCompletedCategory.Loading ->
LoadingScreen(
@@ -499,7 +487,10 @@ fun MandateDetailScreenOfActiveOrCompletedCategory(
mandateDetailOfActiveOrCompletedCategoryViewModel.cancelAPIRequest()
}
.invokeOnCompletion {
if (!bottomSheetState.isVisible) {
if (
!bottomSheetState.isVisible ||
!bottomSheetStateHolder.bottomSheetStateChange
) {
mandateDetailOfActiveOrCompletedCategoryViewModel
.updateBottomSheetUIState(showBottomSheet = false)
}
@@ -742,6 +733,7 @@ fun RenderMandateDetailScreenOfActiveOrCompletedType(
modifier = Modifier.fillMaxWidth(),
bottomSheetState = bottomSheetState,
onDismissRequest = onDismissBottomSheet,
shouldDismissOnBackPress = true,
bottomSheetContent = {
MandateDetailOfActiveCategoryBottomSheetContent(
bottomSheetUIState = bottomSheetStateHolder.bottomSheetUIState,
@@ -862,7 +854,13 @@ private fun RenderMandateDetailsSection(
}
}
Row(modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Row(
modifier =
Modifier.fillMaxWidth().clickableDebounce(showRipple = false) {
onPreviousTransactionToggleClicked()
},
verticalAlignment = Alignment.CenterVertically
) {
NaviText(
text = stringResource(id = R.string.previous_transactions),
fontSize = 16.sp,
@@ -875,10 +873,7 @@ private fun RenderMandateDetailsSection(
Spacer(modifier = Modifier.weight(1f))
Image(
modifier =
Modifier.size(24.dp)
.rotate(if (isPreviousTransactionsVisible) 180f else 0f)
.clickableDebounce(showRipple = false) { onPreviousTransactionToggleClicked() },
modifier = Modifier.size(24.dp).rotate(if (isPreviousTransactionsVisible) 180f else 0f),
painter = painterResource(id = CommonR.drawable.ic_chevron_down),
contentDescription = ""
)

View File

@@ -363,7 +363,7 @@ constructor(
updateUiState(ModifyMandateScreenState.MainScreen)
if (!updateLiteMandateDetailsApiResponse.isSuccessWithData()) {
notifyError(response = updateLiteMandateDetailsApiResponse)
notifyError(response = updateLiteMandateDetailsApiResponse, cancelable = false)
return@launch
}
@@ -455,7 +455,7 @@ constructor(
if (!revokeMandateApiResponse.isSuccessWithData()) {
updateUiState(ModifyMandateScreenState.MainScreen)
notifyError(revokeMandateApiResponse)
notifyError(revokeMandateApiResponse, cancelable = false)
return@launch
}

View File

@@ -868,6 +868,7 @@ constructor(
mandateRepository.revokeMandate(revokeMandateRequest = revokeMandateRequest)
if (!revokeMandateAPIResponse.isSuccessWithData()) {
updateUIState(uiState = LinkedAccountDetailScreenUIState.AccountDetail)
updateBottomSheetUIState(
showBottomSheet = true,
bottomSheetState =
@@ -900,6 +901,7 @@ constructor(
}
is NpciResult.Error -> {
if (!npciResult.isUserAborted) {
updateUIState(uiState = LinkedAccountDetailScreenUIState.AccountDetail)
notifyError()
}
}