Add label when checking donation.

This commit is contained in:
Alex Hart 2025-01-22 13:38:53 -04:00 committed by GitHub
parent cf3cee0343
commit e0553a59d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 9 deletions

View file

@ -523,7 +523,9 @@ object InAppPaymentsRepository {
) )
} }
InAppPaymentTable.State.PENDING -> { InAppPaymentTable.State.PENDING -> {
if (inAppPayment.data.redemption?.stage == InAppPaymentData.RedemptionState.Stage.REDEMPTION_STARTED) { if (inAppPayment.data.redemption?.keepAlive == true) {
DonationRedemptionJobStatus.PendingKeepAlive
} else if (inAppPayment.data.redemption?.stage == InAppPaymentData.RedemptionState.Stage.REDEMPTION_STARTED) {
DonationRedemptionJobStatus.PendingReceiptRedemption DonationRedemptionJobStatus.PendingReceiptRedemption
} else { } else {
DonationRedemptionJobStatus.PendingReceiptRequest DonationRedemptionJobStatus.PendingReceiptRequest

View file

@ -240,6 +240,8 @@ class DonateToSignalViewModel(
when (it) { when (it) {
is DonationRedemptionJobStatus.PendingExternalVerification -> Optional.ofNullable(it.pendingOneTimeDonation) is DonationRedemptionJobStatus.PendingExternalVerification -> Optional.ofNullable(it.pendingOneTimeDonation)
DonationRedemptionJobStatus.PendingKeepAlive -> error("Invalid state for one time donation")
DonationRedemptionJobStatus.PendingReceiptRedemption, DonationRedemptionJobStatus.PendingReceiptRedemption,
DonationRedemptionJobStatus.PendingReceiptRequest, DonationRedemptionJobStatus.PendingReceiptRequest,
DonationRedemptionJobStatus.FailedSubscription, DonationRedemptionJobStatus.FailedSubscription,

View file

@ -82,6 +82,7 @@ object ActiveSubscriptionPreference {
ManageDonationsState.RedemptionState.IS_PENDING_BANK_TRANSFER -> presentPendingBankTransferState(model) ManageDonationsState.RedemptionState.IS_PENDING_BANK_TRANSFER -> presentPendingBankTransferState(model)
ManageDonationsState.RedemptionState.IN_PROGRESS -> presentInProgressState() ManageDonationsState.RedemptionState.IN_PROGRESS -> presentInProgressState()
ManageDonationsState.RedemptionState.FAILED -> presentFailureState(model) ManageDonationsState.RedemptionState.FAILED -> presentFailureState(model)
ManageDonationsState.RedemptionState.SUBSCRIPTION_REFRESH -> presentRefreshState()
} }
} }
@ -96,6 +97,11 @@ object ActiveSubscriptionPreference {
progress.visible = false progress.visible = false
} }
private fun presentRefreshState() {
expiry.text = context.getString(R.string.MySupportPreference__checking_subscription)
progress.visible = true
}
private fun presentPendingBankTransferState(model: Model) { private fun presentPendingBankTransferState(model: Model) {
expiry.text = context.getString(R.string.MySupportPreference__payment_pending) expiry.text = context.getString(R.string.MySupportPreference__payment_pending)
progress.visible = true progress.visible = true

View file

@ -14,7 +14,7 @@ sealed class DonationRedemptionJobStatus {
/** /**
* No pending/running jobs for a donation type. * No pending/running jobs for a donation type.
*/ */
object None : DonationRedemptionJobStatus() data object None : DonationRedemptionJobStatus()
/** /**
* Donation is pending external user verification (e.g., iDEAL). * Donation is pending external user verification (e.g., iDEAL).
@ -31,26 +31,34 @@ sealed class DonationRedemptionJobStatus {
* *
* For one-time donations, pending donation data available via the store. * For one-time donations, pending donation data available via the store.
*/ */
object PendingReceiptRequest : DonationRedemptionJobStatus() data object PendingReceiptRequest : DonationRedemptionJobStatus()
/** /**
* Donation is at the receipt redemption status. * Donation is at the receipt redemption status.
* *
* For one-time donations, pending donation data available via the store. * For one-time donations, pending donation data available via the store.
*/ */
object PendingReceiptRedemption : DonationRedemptionJobStatus() data object PendingReceiptRedemption : DonationRedemptionJobStatus()
/**
* Donation is being refreshed during a keep-alive.
*
* This is an invalid state for one-time donations.
*/
data object PendingKeepAlive : DonationRedemptionJobStatus()
/** /**
* Representation of a failed subscription job chain derived from no pending/running jobs and * Representation of a failed subscription job chain derived from no pending/running jobs and
* a failure state in the store. * a failure state in the store.
*/ */
object FailedSubscription : DonationRedemptionJobStatus() data object FailedSubscription : DonationRedemptionJobStatus()
fun isInProgress(): Boolean { fun isInProgress(): Boolean {
return when (this) { return when (this) {
is PendingExternalVerification, is PendingExternalVerification,
PendingReceiptRedemption, PendingReceiptRedemption,
PendingReceiptRequest -> true PendingReceiptRequest,
PendingKeepAlive -> true
FailedSubscription, FailedSubscription,
None -> false None -> false

View file

@ -36,15 +36,16 @@ data class ManageDonationsState(
} }
sealed class TransactionState { sealed class TransactionState {
object Init : TransactionState() data object Init : TransactionState()
object NetworkFailure : TransactionState() data object NetworkFailure : TransactionState()
object InTransaction : TransactionState() data object InTransaction : TransactionState()
class NotInTransaction(val activeSubscription: ActiveSubscription) : TransactionState() class NotInTransaction(val activeSubscription: ActiveSubscription) : TransactionState()
} }
enum class RedemptionState { enum class RedemptionState {
NONE, NONE,
IN_PROGRESS, IN_PROGRESS,
SUBSCRIPTION_REFRESH,
IS_PENDING_BANK_TRANSFER, IS_PENDING_BANK_TRANSFER,
FAILED FAILED
} }

View file

@ -145,6 +145,7 @@ class ManageDonationsViewModel : ViewModel() {
return when (status) { return when (status) {
DonationRedemptionJobStatus.FailedSubscription -> ManageDonationsState.RedemptionState.FAILED DonationRedemptionJobStatus.FailedSubscription -> ManageDonationsState.RedemptionState.FAILED
DonationRedemptionJobStatus.None -> ManageDonationsState.RedemptionState.NONE DonationRedemptionJobStatus.None -> ManageDonationsState.RedemptionState.NONE
DonationRedemptionJobStatus.PendingKeepAlive -> ManageDonationsState.RedemptionState.SUBSCRIPTION_REFRESH
is DonationRedemptionJobStatus.PendingExternalVerification, is DonationRedemptionJobStatus.PendingExternalVerification,
DonationRedemptionJobStatus.PendingReceiptRedemption, DonationRedemptionJobStatus.PendingReceiptRedemption,

View file

@ -5828,6 +5828,8 @@
<string name="MySupportPreference__your_bank_transfer_of_s">Your bank transfer of %1$s is pending. Bank transfers can take 1 to 14 business days to complete. </string> <string name="MySupportPreference__your_bank_transfer_of_s">Your bank transfer of %1$s is pending. Bank transfers can take 1 to 14 business days to complete. </string>
<!-- Displayed in the pending help dialog, used to launch user to more details about bank transfers --> <!-- Displayed in the pending help dialog, used to launch user to more details about bank transfers -->
<string name="MySupportPreference__learn_more">Learn more</string> <string name="MySupportPreference__learn_more">Learn more</string>
<!-- Displayed when a subscription refresh is being performed -->
<string name="MySupportPreference__checking_subscription">Checking subscription…</string>
<!-- Title of dialog telling user they need to update signal as it expired --> <!-- Title of dialog telling user they need to update signal as it expired -->
<string name="UpdateSignalExpiredDialog__title">Update Signal</string> <string name="UpdateSignalExpiredDialog__title">Update Signal</string>