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
7 changed files with 31 additions and 9 deletions

View File

@@ -523,7 +523,9 @@ object InAppPaymentsRepository {
)
}
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
} else {
DonationRedemptionJobStatus.PendingReceiptRequest

View File

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

View File

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

View File

@@ -14,7 +14,7 @@ sealed class DonationRedemptionJobStatus {
/**
* No pending/running jobs for a donation type.
*/
object None : DonationRedemptionJobStatus()
data object None : DonationRedemptionJobStatus()
/**
* 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.
*/
object PendingReceiptRequest : DonationRedemptionJobStatus()
data object PendingReceiptRequest : DonationRedemptionJobStatus()
/**
* Donation is at the receipt redemption status.
*
* 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
* a failure state in the store.
*/
object FailedSubscription : DonationRedemptionJobStatus()
data object FailedSubscription : DonationRedemptionJobStatus()
fun isInProgress(): Boolean {
return when (this) {
is PendingExternalVerification,
PendingReceiptRedemption,
PendingReceiptRequest -> true
PendingReceiptRequest,
PendingKeepAlive -> true
FailedSubscription,
None -> false

View File

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

View File

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