@umituz/react-native-subscription 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -26,12 +26,13 @@ interface FirestoreTimestamp {
|
|
|
26
26
|
toDate: () => Date;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
// Document structure when READING from Firestore
|
|
30
|
+
interface UserCreditsDocumentRead {
|
|
30
31
|
textCredits: number;
|
|
31
32
|
imageCredits: number;
|
|
32
|
-
purchasedAt
|
|
33
|
-
lastUpdatedAt
|
|
34
|
-
lastPurchaseAt?: FirestoreTimestamp
|
|
33
|
+
purchasedAt?: FirestoreTimestamp;
|
|
34
|
+
lastUpdatedAt?: FirestoreTimestamp;
|
|
35
|
+
lastPurchaseAt?: FirestoreTimestamp;
|
|
35
36
|
processedPurchases?: string[];
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -60,7 +61,7 @@ export class CreditsRepository extends BaseRepository {
|
|
|
60
61
|
return { success: true, data: undefined };
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
const data = snapshot.data() as
|
|
64
|
+
const data = snapshot.data() as UserCreditsDocumentRead;
|
|
64
65
|
return {
|
|
65
66
|
success: true,
|
|
66
67
|
data: {
|
|
@@ -107,7 +108,7 @@ export class CreditsRepository extends BaseRepository {
|
|
|
107
108
|
let processedPurchases: string[] = [];
|
|
108
109
|
|
|
109
110
|
if (creditsDoc.exists()) {
|
|
110
|
-
const existing = creditsDoc.data() as
|
|
111
|
+
const existing = creditsDoc.data() as UserCreditsDocumentRead;
|
|
111
112
|
processedPurchases = existing.processedPurchases || [];
|
|
112
113
|
|
|
113
114
|
if (purchaseId && processedPurchases.includes(purchaseId)) {
|
|
@@ -122,7 +123,10 @@ export class CreditsRepository extends BaseRepository {
|
|
|
122
123
|
(existing.textCredits || 0) + this.config.textCreditLimit;
|
|
123
124
|
newImageCredits =
|
|
124
125
|
(existing.imageCredits || 0) + this.config.imageCreditLimit;
|
|
125
|
-
|
|
126
|
+
// Keep existing purchasedAt if available, otherwise use server timestamp
|
|
127
|
+
if (existing.purchasedAt) {
|
|
128
|
+
purchasedAt = existing.purchasedAt as unknown as FieldValue;
|
|
129
|
+
}
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
if (purchaseId) {
|