mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 02:39:55 +01:00
Add "your media will be deleted today" mechanism based off last checkin time and media TTL.
This commit is contained in:
committed by
Greyson Parrelli
parent
f16827d9ec
commit
bae86d127f
@@ -59,7 +59,6 @@ import java.util.concurrent.locks.Lock
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
@@ -390,32 +389,6 @@ object InAppPaymentsRepository {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if we are in the timeout period to display the "your backup will be deleted today" message
|
||||
*/
|
||||
@WorkerThread
|
||||
fun getExpiredBackupDeletionState(): ExpiredBackupDeletionState {
|
||||
val inAppPayment = SignalDatabase.inAppPayments.getByLatestEndOfPeriod(InAppPaymentType.RECURRING_BACKUP)
|
||||
if (inAppPayment == null) {
|
||||
Log.w(TAG, "InAppPayment for recurring backup not found for last day check. Clearing check.")
|
||||
SignalStore.inAppPayments.showLastDayToDownloadMediaDialog = false
|
||||
return ExpiredBackupDeletionState.NONE
|
||||
}
|
||||
|
||||
val now = SignalStore.misc.estimatedServerTime.milliseconds
|
||||
val lastEndOfPeriod = inAppPayment.endOfPeriod
|
||||
val displayDialogStart = lastEndOfPeriod + backupExpirationTimeout
|
||||
val displayDialogEnd = lastEndOfPeriod + backupExpirationDeletion
|
||||
|
||||
return if (now in displayDialogStart..displayDialogEnd) {
|
||||
ExpiredBackupDeletionState.DELETE_TODAY
|
||||
} else if (now > displayDialogEnd) {
|
||||
ExpiredBackupDeletionState.EXPIRED
|
||||
} else {
|
||||
ExpiredBackupDeletionState.NONE
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@WorkerThread
|
||||
fun setShouldCancelSubscriptionBeforeNextSubscribeAttempt(subscriber: InAppPaymentSubscriberRecord, shouldCancel: Boolean) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.thoughtcrime.securesms.badges.Badges
|
||||
import org.thoughtcrime.securesms.badges.self.expired.MonthlyDonationCanceledBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.DonationPendingBottomSheet
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.DonationPendingBottomSheetArgs
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.InAppPaymentsRepository
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.thanks.ThanksForYourSupportBottomSheetDialogFragment
|
||||
import org.thoughtcrime.securesms.components.settings.app.subscription.thanks.ThanksForYourSupportBottomSheetDialogFragmentArgs
|
||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||
@@ -140,16 +139,6 @@ class InAppPaymentsBottomSheetDelegate(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SignalStore.inAppPayments.showLastDayToDownloadMediaDialog) {
|
||||
lifecycleDisposable += Single.fromCallable {
|
||||
InAppPaymentsRepository.getExpiredBackupDeletionState()
|
||||
}.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribeBy {
|
||||
if (it == InAppPaymentsRepository.ExpiredBackupDeletionState.DELETE_TODAY) {
|
||||
BackupAlertBottomSheet.create(BackupAlert.MediaWillBeDeletedToday).show(fragmentManager, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isUnexpectedCancellation(inAppPaymentState: InAppPaymentTable.State, inAppPaymentData: InAppPaymentData): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user