mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-02 00:17:41 +01:00
Allow user to cancel in-flight keep-alive donation.
This commit is contained in:
committed by
Cody Henthorne
parent
fadbb0adc5
commit
67a6df57c8
@@ -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())
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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 = {}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user