mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-06 16:28:21 +00:00
android, desktop: offer the badge store lane when test products stand in for a store
This commit is contained in:
+5
-2
@@ -99,6 +99,9 @@ data class BadgeStoreReceipt(
|
||||
// receipt says so.
|
||||
const val useBadgeTestProducts = false
|
||||
|
||||
// test products stand in for a store, so the lane is offered without one
|
||||
val badgeStoreAvailable: Boolean get() = useBadgeTestProducts || platform.androidHasPlatformStore
|
||||
|
||||
private fun testProduct(level: BadgeLevel, period: BadgePeriod, priceMicros: Long) =
|
||||
BadgeProduct(badgeStoreProductId(level, period), "\$${priceMicros / 1_000_000}.00", priceMicros, "USD")
|
||||
|
||||
@@ -161,7 +164,7 @@ object BadgeStore {
|
||||
private val presenting = mutableMapOf<String, Boolean>()
|
||||
|
||||
fun purchaseState(userId: Long?): BadgePurchaseState? {
|
||||
if (!platform.androidHasPlatformStore) return null
|
||||
if (!badgeStoreAvailable) return null
|
||||
val purchases = openStorePurchases(userId)
|
||||
val held = unfinished.value.values.mapNotNull { it.invoiceId }.toSet()
|
||||
return when {
|
||||
@@ -173,7 +176,7 @@ object BadgeStore {
|
||||
}
|
||||
|
||||
fun canBuy(userId: Long?): Boolean =
|
||||
platform.androidHasPlatformStore && reconciledOnce.value && buying.value.isEmpty() && purchaseState(userId) == null
|
||||
badgeStoreAvailable && reconciledOnce.value && buying.value.isEmpty() && purchaseState(userId) == null
|
||||
|
||||
fun setStorePurchases(rhId: Long?, userId: Long, purchases: List<OpenStorePurchase>) {
|
||||
storePurchases.value = Triple(rhId, userId, purchases)
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ fun BadgesSupportSimplexView(modalManager: ModalManager) {
|
||||
Spacer(Modifier.weight(1f))
|
||||
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
if (platform.androidHasPlatformStore) {
|
||||
if (badgeStoreAvailable) {
|
||||
ChooseLevelButton(modalManager)
|
||||
if (badgeBrowserAllowed()) {
|
||||
BuyInBrowserTextButton()
|
||||
|
||||
Reference in New Issue
Block a user