@umituz/react-native-subscription 2.37.8 → 2.37.10
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.10",
|
|
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",
|
|
@@ -4,6 +4,7 @@ import { getCreditsRepository } from "../../infrastructure/CreditsRepositoryMana
|
|
|
4
4
|
import type { UseDeductCreditParams, UseDeductCreditResult } from "./types";
|
|
5
5
|
import type { DeductCreditsResult } from "../../core/Credits";
|
|
6
6
|
import { createDeductCreditMutationConfig, type MutationContext } from "./mutationConfig";
|
|
7
|
+
import { creditsQueryKeys } from "../creditsQueryKeys";
|
|
7
8
|
|
|
8
9
|
export const useDeductCredit = ({
|
|
9
10
|
userId,
|
|
@@ -51,7 +52,7 @@ export const useDeductCredit = ({
|
|
|
51
52
|
const result = await repository.refundCredit(userId, amount);
|
|
52
53
|
if (result.success) {
|
|
53
54
|
// Invalidate queries to refresh credit balance
|
|
54
|
-
await queryClient.invalidateQueries({ queryKey:
|
|
55
|
+
await queryClient.invalidateQueries({ queryKey: creditsQueryKeys.user(userId) });
|
|
55
56
|
return true;
|
|
56
57
|
}
|
|
57
58
|
return false;
|
|
@@ -58,7 +58,14 @@ export async function startBackgroundInitialization(config: SubscriptionInitConf
|
|
|
58
58
|
console.log('[BackgroundInitializer] Initial RevenueCat userId:', initialRevenueCatUserId || '(undefined - anonymous)');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// Only initialize immediately if we have a real (non-anonymous) user ID.
|
|
62
|
+
// If anonymous, skip and wait for auth listener to provide the real user ID.
|
|
63
|
+
// This prevents a Firestore permission-denied error from querying with an anonymous ID.
|
|
64
|
+
if (initialRevenueCatUserId) {
|
|
65
|
+
await initializeInBackground(initialRevenueCatUserId);
|
|
66
|
+
} else if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
67
|
+
console.log('[BackgroundInitializer] Skipping anonymous init, waiting for auth state');
|
|
68
|
+
}
|
|
62
69
|
|
|
63
70
|
const unsubscribe = setupAuthStateListener(() => auth, debouncedInitialize);
|
|
64
71
|
|
|
@@ -8,7 +8,7 @@ export interface SubscriptionInitModuleConfig extends Omit<SubscriptionInitConfi
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function createSubscriptionInitModule(config: SubscriptionInitModuleConfig): InitModule {
|
|
11
|
-
const { getApiKey, critical =
|
|
11
|
+
const { getApiKey, critical = false, dependsOn = ['auth'], ...subscriptionConfig } = config;
|
|
12
12
|
|
|
13
13
|
return {
|
|
14
14
|
name: 'subscription',
|