@umituz/react-native-subscription 2.37.16 → 2.37.17
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.17",
|
|
4
4
|
"description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Subscription Packages Hook
|
|
3
|
-
* TanStack query for fetching available packages
|
|
3
|
+
* TanStack query for fetching available packages (offerings)
|
|
4
4
|
* Auth info automatically read from @umituz/react-native-auth
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: Packages (offerings) are NOT user-specific - they're the same
|
|
7
|
+
* for all users. We only need RevenueCat to be initialized, not necessarily
|
|
8
|
+
* for a specific user. User-specific checks belong in useSubscriptionStatus.
|
|
5
9
|
*/
|
|
6
10
|
|
|
7
11
|
import { useQuery, useQueryClient } from "@umituz/react-native-design-system";
|
|
@@ -34,17 +38,14 @@ export const useSubscriptionPackages = () => {
|
|
|
34
38
|
initializationState.getSnapshot,
|
|
35
39
|
);
|
|
36
40
|
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
: initState.initialized || SubscriptionManager.isInitialized();
|
|
41
|
+
// Packages (offerings) are NOT user-specific - same for all users.
|
|
42
|
+
// We only need RevenueCat to be initialized at all.
|
|
43
|
+
// Use reactive state OR direct manager check for backwards compatibility.
|
|
44
|
+
const isInitialized = initState.initialized || SubscriptionManager.isInitialized();
|
|
42
45
|
|
|
43
46
|
const query = useQuery({
|
|
44
47
|
queryKey: [...SUBSCRIPTION_QUERY_KEYS.packages, userId ?? "anonymous"] as const,
|
|
45
48
|
queryFn: async () => {
|
|
46
|
-
// No side effects - just fetch packages
|
|
47
|
-
// Initialization is handled by BackgroundInitializer
|
|
48
49
|
return SubscriptionManager.getPackages();
|
|
49
50
|
},
|
|
50
51
|
enabled: isConfigured && isInitialized,
|
|
@@ -45,7 +45,10 @@ export function detectRenewal(
|
|
|
45
45
|
const newExpiration = new Date(newExpirationDate).getTime();
|
|
46
46
|
const previousExpiration = new Date(state.previousExpirationDate).getTime();
|
|
47
47
|
const productChanged = productId !== state.previousProductId;
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
// Guard against NaN from invalid date strings - treat as no extension
|
|
50
|
+
const expirationExtended =
|
|
51
|
+
!isNaN(newExpiration) && !isNaN(previousExpiration) && newExpiration > previousExpiration;
|
|
49
52
|
|
|
50
53
|
if (productChanged) {
|
|
51
54
|
const oldTier = getPackageTier(state.previousProductId);
|