mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-23 18:30:20 +01:00
Add better handling for unexpected cancellations.
This commit is contained in:
committed by
Cody Henthorne
parent
77f8489e51
commit
588663b3c2
@@ -31,6 +31,7 @@ import org.thoughtcrime.securesms.jobs.RemoteConfigRefreshJob
|
||||
import org.thoughtcrime.securesms.jobs.RetrieveRemoteAnnouncementsJob
|
||||
import org.thoughtcrime.securesms.jobs.RotateProfileKeyJob
|
||||
import org.thoughtcrime.securesms.jobs.StorageForcePushJob
|
||||
import org.thoughtcrime.securesms.jobs.SubscriptionKeepAliveJob
|
||||
import org.thoughtcrime.securesms.jobs.SubscriptionReceiptRequestResponseJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.payments.DataExportUtil
|
||||
@@ -401,6 +402,13 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
enqueueSubscriptionRedemption()
|
||||
}
|
||||
)
|
||||
|
||||
clickPref(
|
||||
title = DSLSettingsText.from(R.string.preferences__internal_badges_enqueue_keep_alive),
|
||||
onClick = {
|
||||
enqueueSubscriptionKeepAlive()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
dividerPref()
|
||||
@@ -573,6 +581,10 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter
|
||||
SubscriptionReceiptRequestResponseJob.createSubscriptionContinuationJobChain().enqueue()
|
||||
}
|
||||
|
||||
private fun enqueueSubscriptionKeepAlive() {
|
||||
SubscriptionKeepAliveJob.enqueueAndTrackTime(System.currentTimeMillis())
|
||||
}
|
||||
|
||||
private fun clearCdsHistory() {
|
||||
SignalDatabase.cds.clearAll()
|
||||
SignalStore.misc().cdsToken = null
|
||||
|
||||
@@ -277,9 +277,8 @@ class DonationPaymentRepository(activity: Activity) : StripeApi.PaymentIntentFet
|
||||
).flatMapCompletable {
|
||||
if (it.status == 200 || it.status == 204) {
|
||||
Log.d(TAG, "Successfully set user subscription to level $subscriptionLevel with response code ${it.status}", true)
|
||||
SignalStore.donationsValues().clearUserManuallyCancelled()
|
||||
SignalStore.donationsValues().updateLocalStateForLocalSubscribe()
|
||||
scheduleSyncForAccountRecordChange()
|
||||
SignalStore.donationsValues().clearLevelOperations()
|
||||
LevelUpdate.updateProcessingState(false)
|
||||
Completable.complete()
|
||||
} else {
|
||||
|
||||
@@ -164,12 +164,7 @@ class SubscribeViewModel(
|
||||
return Single.just(SignalStore.donationsValues().shouldCancelSubscriptionBeforeNextSubscribeAttempt).flatMapCompletable {
|
||||
if (it) {
|
||||
donationPaymentRepository.cancelActiveSubscription().doOnComplete {
|
||||
SignalStore.donationsValues().setLastEndOfPeriod(0L)
|
||||
SignalStore.donationsValues().clearLevelOperations()
|
||||
SignalStore.donationsValues().shouldCancelSubscriptionBeforeNextSubscribeAttempt = false
|
||||
SignalStore.donationsValues().setUnexpectedSubscriptionCancelationChargeFailure(null)
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationReason = null
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation()
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue()
|
||||
}
|
||||
} else {
|
||||
@@ -183,12 +178,7 @@ class SubscribeViewModel(
|
||||
disposables += donationPaymentRepository.cancelActiveSubscription().subscribeBy(
|
||||
onComplete = {
|
||||
eventPublisher.onNext(DonationEvent.SubscriptionCancelled)
|
||||
SignalStore.donationsValues().setLastEndOfPeriod(0L)
|
||||
SignalStore.donationsValues().clearLevelOperations()
|
||||
SignalStore.donationsValues().markUserManuallyCancelled()
|
||||
SignalStore.donationsValues().setUnexpectedSubscriptionCancelationChargeFailure(null)
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationReason = null
|
||||
SignalStore.donationsValues().unexpectedSubscriptionCancelationTimestamp = 0L
|
||||
SignalStore.donationsValues().updateLocalStateForManualCancellation()
|
||||
refreshActiveSubscription()
|
||||
MultiDeviceSubscriptionSyncRequestJob.enqueue()
|
||||
donationPaymentRepository.scheduleSyncForAccountRecordChange()
|
||||
|
||||
Reference in New Issue
Block a user