@umituz/react-native-onboarding 3.0.2 → 3.0.3

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-onboarding",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Advanced onboarding flow for React Native apps with personalization questions, theme-aware colors, animations, and customizable slides. SOLID, DRY, KISS principles applied.",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -63,22 +63,32 @@ export function createOnboardingStoreActions(
63
63
  try {
64
64
  set({ loading: true, error: null });
65
65
 
66
+ // Ensure storage write completes before proceeding
66
67
  const result = await storageRepository.setString(storageKey, "true");
67
68
 
69
+ if (!result.success) {
70
+ throw new Error("Failed to save completion status to storage");
71
+ }
72
+
68
73
  const userData = { ...get().userData };
69
74
  userData.completedAt = new Date().toISOString();
70
75
 
71
- await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
76
+ const userDataResult = await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
72
77
 
78
+ if (!userDataResult.success) {
79
+ throw new Error("Failed to save user data to storage");
80
+ }
81
+
82
+ // Only update state after storage write is confirmed
73
83
  set({
74
- isOnboardingComplete: result.success,
84
+ isOnboardingComplete: true,
75
85
  userData,
76
86
  loading: false,
77
- error: result.success ? null : "Failed to complete onboarding",
87
+ error: null,
78
88
  });
79
89
 
80
90
  if (__DEV__) {
81
- console.log('[OnboardingStore] Onboarding completed successfully');
91
+ console.log('[OnboardingStore] Onboarding completed and persisted successfully');
82
92
  }
83
93
  } catch (error) {
84
94
  set({
@@ -89,6 +99,8 @@ export function createOnboardingStoreActions(
89
99
  if (__DEV__) {
90
100
  console.error('[OnboardingStore] Completion error:', error);
91
101
  }
102
+
103
+ throw error;
92
104
  }
93
105
  },
94
106
 
@@ -96,22 +108,33 @@ export function createOnboardingStoreActions(
96
108
  try {
97
109
  set({ loading: true, error: null });
98
110
 
111
+ // Ensure storage write completes before proceeding
99
112
  const result = await storageRepository.setString(storageKey, "true");
100
113
 
114
+ if (!result.success) {
115
+ throw new Error("Failed to save skip status to storage");
116
+ }
117
+
101
118
  const userData = { ...get().userData };
102
119
  userData.skipped = true;
103
120
  userData.completedAt = new Date().toISOString();
104
- await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
105
121
 
122
+ const userDataResult = await storageRepository.setItem(USER_DATA_STORAGE_KEY, userData);
123
+
124
+ if (!userDataResult.success) {
125
+ throw new Error("Failed to save user data to storage");
126
+ }
127
+
128
+ // Only update state after storage write is confirmed
106
129
  set({
107
- isOnboardingComplete: result.success,
130
+ isOnboardingComplete: true,
108
131
  userData,
109
132
  loading: false,
110
- error: result.success ? null : "Failed to skip onboarding",
133
+ error: null,
111
134
  });
112
135
 
113
136
  if (__DEV__) {
114
- console.log('[OnboardingStore] Onboarding skipped successfully');
137
+ console.log('[OnboardingStore] Onboarding skipped and persisted successfully');
115
138
  }
116
139
  } catch (error) {
117
140
  set({
@@ -122,6 +145,8 @@ export function createOnboardingStoreActions(
122
145
  if (__DEV__) {
123
146
  console.error('[OnboardingStore] Skip error:', error);
124
147
  }
148
+
149
+ throw error;
125
150
  }
126
151
  },
127
152