Skip to content

Commit e60040c

Browse files
committed
Cleanup comments
1 parent 60ef32a commit e60040c

File tree

11 files changed

+80
-83
lines changed

11 files changed

+80
-83
lines changed

superwall/src/main/java/com/superwall/sdk/customer/CustomerInfoManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ class CustomerInfoManager(
8888
// Merge with optimization: skip merge if one source is blank
8989
merged =
9090
when {
91-
deviceInfo.isBlank && webInfo.isBlank -> CustomerInfo.empty()
92-
deviceInfo.isBlank -> webInfo
93-
webInfo.isBlank -> deviceInfo
91+
deviceInfo.isPlaceholder && webInfo.isPlaceholder -> CustomerInfo.empty()
92+
deviceInfo.isPlaceholder -> webInfo
93+
webInfo.isPlaceholder -> deviceInfo
9494
else -> deviceInfo.merge(webInfo) // Apply priority-based merging
9595
}
9696

superwall/src/main/java/com/superwall/sdk/dependencies/DependencyContainer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ class DependencyContainer(
260260
StoreManager(
261261
purchaseController = purchaseController,
262262
billing = googleBillingWrapper,
263-
storage = storage,
264-
customerInfoManager = { customerInfoManager },
265263
receiptManagerFactory = {
266264
ReceiptManager(
267265
delegate = storeManager,

superwall/src/main/java/com/superwall/sdk/models/customer/CustomerInfo.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ data class CustomerInfo(
3030
/** All entitlements available to the user. */
3131
@SerialName("entitlements")
3232
val entitlements: List<Entitlement>,
33-
/** Internally set to `true` on first ever load of CustomerInfo. */
34-
@SerialName("isBlank")
35-
internal val isBlank: Boolean = false,
33+
/** Indicates whether this is a placeholder CustomerInfo that hasn't been populated with real data yet.
34+
* true means this is the initial placeholder state before data has been loaded.
35+
* false means real data has been loaded (even if that data is empty)
36+
* */
37+
@SerialName("isPlaceholder")
38+
internal val isPlaceholder: Boolean = false,
3639
) {
3740
/** A Set of the product identifiers for the active subscriptions. */
3841
@Transient
@@ -53,7 +56,7 @@ data class CustomerInfo(
5356
nonSubscriptions = emptyList(),
5457
userId = "",
5558
entitlements = emptyList(),
56-
isBlank = true,
59+
isPlaceholder = true,
5760
)
5861

5962
/**
@@ -116,7 +119,7 @@ data class CustomerInfo(
116119
nonSubscriptions = baseCustomerInfo.nonSubscriptions,
117120
userId = baseCustomerInfo.userId,
118121
entitlements = finalEntitlements,
119-
isBlank = false,
122+
isPlaceholder = false,
120123
)
121124
}
122125
}

superwall/src/main/java/com/superwall/sdk/models/customer/CustomerInfoMerging.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fun CustomerInfo.merge(other: CustomerInfo): CustomerInfo {
7979
nonSubscriptions = mergedNonSubscriptions,
8080
userId = mergedUserId,
8181
entitlements = mergedEntitlements,
82-
isBlank = isBlank,
82+
isPlaceholder = isBlank,
8383
)
8484
}
8585

superwall/src/main/java/com/superwall/sdk/models/entitlements/Entitlement.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("ktlint:standard:no-blank-line-in-list")
2+
13
package com.superwall.sdk.models.entitlements
24

35
import android.annotation.SuppressLint
@@ -25,9 +27,9 @@ data class Entitlement(
2527
*/
2628
@SerialName("type")
2729
val type: Type = Type.SERVICE_LEVEL,
30+
// region: Device-enriched properties (added on device after retrieving from server)
31+
2832
/**
29-
*Added on device after retrieving from server.
30-
*
3133
* Indicates whether there is any active, non-revoked, transaction for this entitlement.
3234
*/
3335
@SerialName("isActive")
@@ -42,14 +44,14 @@ data class Entitlement(
4244
*
4345
* If one or more lifetime products unlock this entitlement, the `latestProductId` will always be the product identifier of the first lifetime product.
4446
*
45-
* This is `null` if there aren't any transactions that unlock this entitlement.
47+
* This is `null` if there aren't any transactions that unlock this entitlement or if it was manually granted from Superwall.
4648
*/
4749
@SerialName("latestProductId")
4850
val latestProductId: String? = null,
4951
/**
5052
* The purchase date of the first transaction that unlocked this entitlement.
5153
*
52-
* This is `null` if there aren't any transactions that unlock this entitlement.
54+
* This is `null` if there aren't any transactions that unlock this entitlement or if it was manually granted from Superwall.
5355
*/
5456
@SerialName("startsAt")
5557
@Contextual
@@ -68,7 +70,7 @@ data class Entitlement(
6870
/**
6971
* The expiry date of the last transaction that unlocked this entitlement.
7072
*
71-
* This is `null` if there aren't any transactions that unlock this entitlement or
73+
* This is `null` if there aren't any transactions that unlock this entitlement, if it was manually granted from Superwall or
7274
* if a lifetime product unlocked this entitlement.
7375
*/
7476
@SerialName("expiresAt")
@@ -92,15 +94,15 @@ data class Entitlement(
9294
* The state of the last subscription transaction associated with the
9395
* entitlement.
9496
*
95-
* This is `null` if there aren't any transactions that unlock this entitlement.
97+
* This is `null` if there aren't any transactions that unlock this entitlement or if it was manually granted from Superwall.
9698
*/
9799
@SerialName("state")
98100
val state: LatestSubscriptionState? = null,
99101
/**
100102
* The type of offer that applies to the last subscription transaction that
101103
* unlocks this entitlement.
102104
*
103-
* This is `null` if there aren't any transactions that unlock this entitlement.
105+
* This is `null` if there aren't any transactions that unlock this entitlement or if it was manually granted from Superwall.
104106
*
105107
* Note: This is only non-`null` on Android API 21+.
106108
*/
@@ -109,7 +111,7 @@ data class Entitlement(
109111
/**
110112
* The store where the product that unlocked this entitlement was purchased.
111113
*
112-
* This is `null` if there aren't any transactions that unlock this entitlement.
114+
* This is `null` if there aren't any transactions that unlock this entitlement or if it was manually granted from Superwall.
113115
*/
114116
@SerialName("store")
115117
val store: Store? = null,
@@ -119,7 +121,7 @@ data class Entitlement(
119121
val raw: String,
120122
) {
121123
/**
122-
* An Store product.
124+
* A Superwall service level entitlement.
123125
*/
124126
@SerialName("SERVICE_LEVEL")
125127
SERVICE_LEVEL("SERVICE_LEVEL"),

superwall/src/main/java/com/superwall/sdk/store/abstractions/product/receipt/ReceiptManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ReceiptManager(
161161
.flatten()
162162
.distinctBy { it.id }
163163
.toList(),
164-
isBlank = subscriptions.isEmpty() && nonSubscriptions.isEmpty(),
164+
isPlaceholder = subscriptions.isEmpty() && nonSubscriptions.isEmpty(),
165165
)
166166

167167
// Store device CustomerInfo

superwall/src/main/java/com/superwall/sdk/web/WebPaywallRedeemer.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.superwall.sdk.web
22

33
import android.content.Context
4-
import com.superwall.sdk.analytics.internal.track
54
import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent
65
import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent.Redemptions
76
import com.superwall.sdk.analytics.internal.trackable.InternalSuperwallEvent.Redemptions.RedemptionState
@@ -34,7 +33,6 @@ import com.superwall.sdk.utilities.withErrorTracking
3433
import kotlinx.coroutines.Dispatchers
3534
import kotlinx.coroutines.Job
3635
import kotlinx.coroutines.delay
37-
import kotlinx.coroutines.flow.map
3836
import kotlinx.coroutines.launch
3937
import kotlinx.coroutines.plus
4038
import kotlinx.serialization.json.JsonArray
@@ -343,7 +341,7 @@ class WebPaywallRedeemer(
343341
nonSubscriptions = emptyList(),
344342
userId = userId?.value ?: "",
345343
entitlements = emptyList(),
346-
isBlank = false,
344+
isPlaceholder = false,
347345
)
348346
}
349347

@@ -426,7 +424,7 @@ class WebPaywallRedeemer(
426424
nonSubscriptions = emptyList(),
427425
userId = "",
428426
entitlements = newEntitlements.toList(),
429-
isBlank = false,
427+
isPlaceholder = false,
430428
)
431429
val updatedResponse =
432430
latestRedeemResponse.copy(

superwall/src/test/java/com/superwall/sdk/customer/CustomerInfoManagerTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CustomerInfoManagerTest {
6565
nonSubscriptions = emptyList(),
6666
userId = "user123",
6767
entitlements = emptyList(),
68-
isBlank = false,
68+
isPlaceholder = false,
6969
)
7070

7171
val webInfo =
@@ -87,7 +87,7 @@ class CustomerInfoManagerTest {
8787
nonSubscriptions = emptyList(),
8888
userId = "",
8989
entitlements = emptyList(),
90-
isBlank = false,
90+
isPlaceholder = false,
9191
)
9292

9393
every { storage.read(LatestDeviceCustomerInfo) } returns deviceInfo
@@ -123,7 +123,7 @@ class CustomerInfoManagerTest {
123123
nonSubscriptions = emptyList(),
124124
userId = "user123",
125125
entitlements = emptyList(),
126-
isBlank = false,
126+
isPlaceholder = false,
127127
)
128128

129129
every { storage.read(LatestDeviceCustomerInfo) } returns deviceInfo
@@ -158,7 +158,7 @@ class CustomerInfoManagerTest {
158158
nonSubscriptions = emptyList(),
159159
userId = "webuser",
160160
entitlements = emptyList(),
161-
isBlank = false,
161+
isPlaceholder = false,
162162
)
163163

164164
every { storage.read(LatestDeviceCustomerInfo) } returns null
@@ -180,8 +180,8 @@ class CustomerInfoManagerTest {
180180
manager.updateMergedCustomerInfo()
181181
testDispatcher.scheduler.advanceUntilIdle()
182182

183-
verify { storage.write(LatestCustomerInfo, match { it.isBlank }) }
184-
assert(customerInfoFlow.value.isBlank)
183+
verify { storage.write(LatestCustomerInfo, match { it.isPlaceholder }) }
184+
assert(customerInfoFlow.value.isPlaceholder)
185185
}
186186

187187
// Tests for external purchase controller flow
@@ -215,7 +215,7 @@ class CustomerInfoManagerTest {
215215
nonSubscriptions = emptyList(),
216216
userId = "user123",
217217
entitlements = listOf(deviceEntitlement),
218-
isBlank = false,
218+
isPlaceholder = false,
219219
)
220220

221221
val webCustomerInfo =
@@ -224,7 +224,7 @@ class CustomerInfoManagerTest {
224224
nonSubscriptions = emptyList(),
225225
userId = "",
226226
entitlements = listOf(webEntitlement),
227-
isBlank = false,
227+
isPlaceholder = false,
228228
)
229229

230230
val subscriptionStatus =
@@ -341,7 +341,7 @@ class CustomerInfoManagerTest {
341341
nonSubscriptions = emptyList(),
342342
userId = "user123",
343343
entitlements = emptyList(),
344-
isBlank = false,
344+
isPlaceholder = false,
345345
)
346346

347347
val webCustomerInfo =
@@ -350,7 +350,7 @@ class CustomerInfoManagerTest {
350350
nonSubscriptions = emptyList(),
351351
userId = "",
352352
entitlements = emptyList(),
353-
isBlank = false,
353+
isPlaceholder = false,
354354
)
355355

356356
every { storage.read(LatestDeviceCustomerInfo) } returns deviceInfo

0 commit comments

Comments
 (0)