Fix hot loop when creating a subscription to remote backups.

This commit is contained in:
Alex Hart 2024-12-05 13:49:07 -04:00 committed by Greyson Parrelli
parent 5e10ccc969
commit 0c86ff1f84
2 changed files with 12 additions and 2 deletions

View file

@ -95,6 +95,18 @@ class MessageBackupsFlowViewModel(
Log.d(TAG, "Got successful purchase result for purchase at ${result.purchaseTime}")
val id = internalStateFlow.value.inAppPayment!!.id
if (result.isAcknowledged) {
Log.w(TAG, "Payment is already acknowledged. Ignoring.")
internalStateFlow.update {
it.copy(
stage = MessageBackupsStage.COMPLETED
)
}
return@collect
}
try {
Log.d(TAG, "Attempting to handle successful purchase.")

View file

@ -202,8 +202,6 @@ internal class BillingApiImpl(
billingClient.queryPurchasesAsync(param)
}
purchasesUpdatedListener.onPurchasesUpdated(result.billingResult, result.purchasesList)
val purchase = result.purchasesList.maxByOrNull { it.purchaseTime } ?: return BillingPurchaseResult.None
return BillingPurchaseResult.Success(