Allow user to cancel in-flight keep-alive donation.

This commit is contained in:
Alex Hart
2026-02-23 14:48:16 -04:00
committed by Cody Henthorne
parent fadbb0adc5
commit 67a6df57c8
5 changed files with 6 additions and 11 deletions

View File

@@ -310,7 +310,7 @@ class DonateToSignalFragment :
text = DSLSettingsText.from(R.string.SubscribeFragment__cancel_subscription),
isEnabled = state.areFieldsEnabled,
onClick = {
if (state.monthlyDonationState.transactionState.isTransactionJobPending) {
if (state.monthlyDonationState.transactionState.isTransactionJobPending && !state.monthlyDonationState.transactionState.isKeepAlive) {
showDonationPendingDialog(state)
} else {
MaterialAlertDialogBuilder(requireContext())

View File

@@ -139,7 +139,8 @@ data class DonateToSignalState(
data class TransactionState(
val isTransactionJobPending: Boolean = false,
val isLevelUpdateInProgress: Boolean = false
val isLevelUpdateInProgress: Boolean = false,
val isKeepAlive: Boolean = false
) {
val isInProgress: Boolean = isTransactionJobPending || isLevelUpdateInProgress
}

View File

@@ -341,7 +341,7 @@ class DonateToSignalViewModel(
state.copy(
monthlyDonationState = state.monthlyDonationState.copy(
nonVerifiedMonthlyDonation = if (jobStatus is DonationRedemptionJobStatus.PendingExternalVerification) jobStatus.nonVerifiedMonthlyDonation else null,
transactionState = DonateToSignalState.TransactionState(jobStatus.isInProgress(), levelUpdateProcessing)
transactionState = DonateToSignalState.TransactionState(jobStatus.isInProgress(), levelUpdateProcessing, jobStatus is DonationRedemptionJobStatus.PendingKeepAlive)
)
)
}

View File

@@ -34,7 +34,6 @@ object ActiveSubscriptionPreference {
val activeSubscription: ActiveSubscription.Subscription?,
val subscriberRequiresCancel: Boolean,
val onContactSupport: () -> Unit,
val onPendingClick: (FiatMoney) -> Unit,
val onRowClick: (ManageDonationsState.RedemptionState) -> Unit
) : PreferenceModel<Model>() {
override fun areItemsTheSame(newItem: Model): Boolean {
@@ -79,7 +78,7 @@ object ActiveSubscriptionPreference {
when (model.redemptionState) {
ManageDonationsState.RedemptionState.NONE -> presentRenewalState(model)
ManageDonationsState.RedemptionState.IS_PENDING_BANK_TRANSFER -> presentPendingBankTransferState(model)
ManageDonationsState.RedemptionState.IS_PENDING_BANK_TRANSFER -> presentPendingBankTransferState()
ManageDonationsState.RedemptionState.IN_PROGRESS -> presentInProgressState()
ManageDonationsState.RedemptionState.FAILED -> presentFailureState(model)
ManageDonationsState.RedemptionState.SUBSCRIPTION_REFRESH -> presentRefreshState()
@@ -102,10 +101,9 @@ object ActiveSubscriptionPreference {
progress.visible = true
}
private fun presentPendingBankTransferState(model: Model) {
private fun presentPendingBankTransferState() {
expiry.text = context.getString(R.string.MySupportPreference__payment_pending)
progress.visible = true
itemView.setOnClickListener { model.onPendingClick(model.price) }
}
private fun presentInProgressState() {

View File

@@ -294,9 +294,6 @@ class ManageDonationsFragment :
subscriberRequiresCancel = state.subscriberRequiresCancel,
onRowClick = {
launcher.launch(InAppPaymentType.RECURRING_DONATION)
},
onPendingClick = {
displayPendingDialog(it)
}
)
)
@@ -317,7 +314,6 @@ class ManageDonationsFragment :
onContactSupport = {},
activeSubscription = null,
subscriberRequiresCancel = state.subscriberRequiresCancel,
onPendingClick = {},
onRowClick = {}
)
)