@umituz/react-native-subscription 2.24.0 → 2.24.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.24.0",
3
+ "version": "2.24.1",
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",
@@ -57,21 +57,24 @@ export function useFeatureGate(
57
57
 
58
58
  // Store pending action for execution after purchase
59
59
  const pendingActionRef = useRef<(() => void | Promise<void>) | null>(null);
60
- const prevHasCreditsRef = useRef(hasCredits);
60
+ const prevCreditBalanceRef = useRef(creditBalance);
61
+ const isWaitingForPurchaseRef = useRef(false);
61
62
 
62
- // Execute pending action when credits become available
63
+ // Execute pending action when credits increase after purchase
63
64
  useEffect(() => {
64
- const hadNoCredits = !prevHasCreditsRef.current;
65
- const nowHasCredits = hasCredits;
65
+ const prevBalance = prevCreditBalanceRef.current;
66
+ const currentBalance = creditBalance;
67
+ const creditsIncreased = currentBalance > prevBalance;
66
68
 
67
- if (hadNoCredits && nowHasCredits && pendingActionRef.current) {
69
+ if (isWaitingForPurchaseRef.current && creditsIncreased && pendingActionRef.current) {
68
70
  const action = pendingActionRef.current;
69
71
  pendingActionRef.current = null;
72
+ isWaitingForPurchaseRef.current = false;
70
73
  action();
71
74
  }
72
75
 
73
- prevHasCreditsRef.current = hasCredits;
74
- }, [hasCredits]);
76
+ prevCreditBalanceRef.current = creditBalance;
77
+ }, [creditBalance]);
75
78
 
76
79
  // Compose individual gates
77
80
  const authGate = useAuthGate({
@@ -110,6 +113,7 @@ export function useFeatureGate(
110
113
  if (!creditsGate.requireCredits(() => {})) {
111
114
  // Store pending action for execution after purchase
112
115
  pendingActionRef.current = action;
116
+ isWaitingForPurchaseRef.current = true;
113
117
  return;
114
118
  }
115
119