Fix hot loop when creating a subscription to remote backups.
This commit is contained in:
parent
5e10ccc969
commit
0c86ff1f84
2 changed files with 12 additions and 2 deletions
|
@ -95,6 +95,18 @@ class MessageBackupsFlowViewModel(
|
||||||
Log.d(TAG, "Got successful purchase result for purchase at ${result.purchaseTime}")
|
Log.d(TAG, "Got successful purchase result for purchase at ${result.purchaseTime}")
|
||||||
val id = internalStateFlow.value.inAppPayment!!.id
|
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 {
|
try {
|
||||||
Log.d(TAG, "Attempting to handle successful purchase.")
|
Log.d(TAG, "Attempting to handle successful purchase.")
|
||||||
|
|
||||||
|
|
|
@ -202,8 +202,6 @@ internal class BillingApiImpl(
|
||||||
billingClient.queryPurchasesAsync(param)
|
billingClient.queryPurchasesAsync(param)
|
||||||
}
|
}
|
||||||
|
|
||||||
purchasesUpdatedListener.onPurchasesUpdated(result.billingResult, result.purchasesList)
|
|
||||||
|
|
||||||
val purchase = result.purchasesList.maxByOrNull { it.purchaseTime } ?: return BillingPurchaseResult.None
|
val purchase = result.purchasesList.maxByOrNull { it.purchaseTime } ?: return BillingPurchaseResult.None
|
||||||
|
|
||||||
return BillingPurchaseResult.Success(
|
return BillingPurchaseResult.Success(
|
||||||
|
|
Loading…
Add table
Reference in a new issue