From b7f5cd2fa271efe7c419cd9dc78df57ac6e1f33c Mon Sep 17 00:00:00 2001 From: moezbhatti Date: Wed, 10 Apr 2019 22:38:07 -0400 Subject: [PATCH] #1405 - Fix upgrade restoration --- .../java/com/moez/QKSMS/common/util/BillingManager.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManager.kt b/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManager.kt index bc6481ca..1a2919d5 100644 --- a/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManager.kt +++ b/presentation/src/main/java/com/moez/QKSMS/common/util/BillingManager.kt @@ -77,10 +77,13 @@ class BillingManager @Inject constructor( private fun queryPurchases() { executeServiceRequest { - val purchasesResult = billingClient.queryPurchases(SkuType.INAPP) + // Load the cached data + purchaseListObservable.onNext(billingClient.queryPurchases(SkuType.INAPP).purchasesList.orEmpty()) - // Handle purchase result - purchaseListObservable.onNext(purchasesResult.purchasesList.orEmpty()) + // On a fresh device, the purchase might not be cached, and so we'll need to force a refresh + billingClient.queryPurchaseHistoryAsync(SkuType.INAPP) { _, _ -> + purchaseListObservable.onNext(billingClient.queryPurchases(SkuType.INAPP).purchasesList.orEmpty()) + } } }