diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 68de8c8e..0a06873c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -145,6 +145,6 @@ dependencies { addTesting() - "gplayImplementation"("com.android.billingclient:billing:5.1.0") - "gplayImplementation"("com.android.billingclient:billing-ktx:5.1.0") + "gplayImplementation"("com.android.billingclient:billing:6.0.1") + "gplayImplementation"("com.android.billingclient:billing-ktx:6.0.1") } \ No newline at end of file diff --git a/app/src/gplay/java/eu/darken/capod/common/upgrade/core/client/BillingClientConnection.kt b/app/src/gplay/java/eu/darken/capod/common/upgrade/core/client/BillingClientConnection.kt index 741ddd66..971c46e8 100644 --- a/app/src/gplay/java/eu/darken/capod/common/upgrade/core/client/BillingClientConnection.kt +++ b/app/src/gplay/java/eu/darken/capod/common/upgrade/core/client/BillingClientConnection.kt @@ -1,7 +1,13 @@ package eu.darken.capod.common.upgrade.core.client import android.app.Activity -import com.android.billingclient.api.* +import com.android.billingclient.api.AcknowledgePurchaseParams +import com.android.billingclient.api.BillingClient +import com.android.billingclient.api.BillingFlowParams +import com.android.billingclient.api.BillingResult +import com.android.billingclient.api.ProductDetails +import com.android.billingclient.api.Purchase +import com.android.billingclient.api.QueryProductDetailsParams import eu.darken.capod.common.debug.logging.Logging.Priority.INFO import eu.darken.capod.common.debug.logging.Logging.Priority.WARN import eu.darken.capod.common.debug.logging.log @@ -20,11 +26,15 @@ data class BillingClientConnection( ) { private val purchasesLocal = MutableStateFlow>(emptySet()) val purchases: Flow> = combine(purchasesGlobal, purchasesLocal) { global, local -> - val combined = mutableMapOf() - global.plus(local).toSet().sortedByDescending { it.purchaseTime }.forEach { purchase -> - combined[purchase.orderId] = purchase - } - combined.values + val combined = mutableSetOf() + + combined.addAll(local) + + global + .let { purchases -> purchases.filter { it.purchaseState == Purchase.PurchaseState.PURCHASED } } + .let { combined.addAll(it) } + + combined.sortedByDescending { it.purchaseTime } } .setupCommonEventHandlers(TAG) { "purchases" }