@umituz/react-native-settings 5.2.47 → 5.2.49
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-settings",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.49",
|
|
4
4
|
"description": "Complete settings hub for React Native apps - consolidated package with settings, localization, about, legal, appearance, feedback, FAQs, rating, and gamification",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -10,42 +10,44 @@ import { useUpdateSettingsMutation, useResetSettingsMutation } from './mutations
|
|
|
10
10
|
import type { UserSettings } from '../../application/ports/ISettingsRepository';
|
|
11
11
|
|
|
12
12
|
export const useSettings = (userId: string) => {
|
|
13
|
-
|
|
14
|
-
if (!userId || typeof userId !== 'string' || userId.trim() === '') {
|
|
15
|
-
throw new Error(
|
|
16
|
-
'Invalid userId: must be a non-empty string. ' +
|
|
17
|
-
'Received: ' + (userId === null ? 'null' : typeof userId)
|
|
18
|
-
);
|
|
19
|
-
}
|
|
13
|
+
const isValidUserId = !!userId && typeof userId === 'string' && userId.trim() !== '';
|
|
20
14
|
|
|
21
15
|
const {
|
|
22
16
|
data: settings,
|
|
23
17
|
isLoading: loading,
|
|
24
18
|
error: queryError
|
|
25
|
-
} = useSettingsQuery(userId);
|
|
19
|
+
} = useSettingsQuery(isValidUserId ? userId : '__invalid__');
|
|
26
20
|
|
|
27
|
-
const updateMutation = useUpdateSettingsMutation(userId);
|
|
28
|
-
const resetMutation = useResetSettingsMutation(userId);
|
|
21
|
+
const updateMutation = useUpdateSettingsMutation(isValidUserId ? userId : '__invalid__');
|
|
22
|
+
const resetMutation = useResetSettingsMutation(isValidUserId ? userId : '__invalid__');
|
|
29
23
|
|
|
30
24
|
const updateSettings = async (updates: Partial<UserSettings>) => {
|
|
25
|
+
if (!isValidUserId) {
|
|
26
|
+
throw new Error('Invalid userId: must be a non-empty string');
|
|
27
|
+
}
|
|
31
28
|
return updateMutation.mutateAsync(updates);
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
const resetSettings = async () => {
|
|
32
|
+
if (!isValidUserId) {
|
|
33
|
+
throw new Error('Invalid userId: must be a non-empty string');
|
|
34
|
+
}
|
|
35
35
|
return resetMutation.mutateAsync();
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const error =
|
|
39
|
-
?
|
|
40
|
-
:
|
|
41
|
-
?
|
|
42
|
-
:
|
|
43
|
-
?
|
|
44
|
-
:
|
|
38
|
+
const error = !isValidUserId
|
|
39
|
+
? 'Invalid userId: must be a non-empty string'
|
|
40
|
+
: queryError instanceof Error
|
|
41
|
+
? queryError.message
|
|
42
|
+
: updateMutation.error instanceof Error
|
|
43
|
+
? updateMutation.error.message
|
|
44
|
+
: resetMutation.error instanceof Error
|
|
45
|
+
? resetMutation.error.message
|
|
46
|
+
: null;
|
|
45
47
|
|
|
46
48
|
return {
|
|
47
|
-
settings,
|
|
48
|
-
loading: loading || updateMutation.isPending || resetMutation.isPending,
|
|
49
|
+
settings: isValidUserId ? settings : undefined,
|
|
50
|
+
loading: isValidUserId ? (loading || updateMutation.isPending || resetMutation.isPending) : false,
|
|
49
51
|
error,
|
|
50
52
|
updateSettings,
|
|
51
53
|
resetSettings,
|