@oxyhq/services 5.13.3 → 5.13.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/lib/commonjs/core/HttpClient.js +1 -1
- package/lib/commonjs/core/HttpClient.js.map +1 -1
- package/lib/commonjs/core/OxyServices.js +82 -8
- package/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/i18n/locales/en-US.json +222 -6
- package/lib/commonjs/lib/sonner.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +24 -22
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +35 -14
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/navigation/routes.js +36 -1
- package/lib/commonjs/ui/navigation/routes.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +150 -5
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +475 -319
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountVerificationScreen.js +217 -0
- package/lib/commonjs/ui/screens/AccountVerificationScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/FileManagementScreen.js +911 -213
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/HelpSupportScreen.js +131 -0
- package/lib/commonjs/ui/screens/HelpSupportScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/HistoryViewScreen.js +258 -0
- package/lib/commonjs/ui/screens/HistoryViewScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js +211 -0
- package/lib/commonjs/ui/screens/LegalDocumentsScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js +0 -1
- package/lib/commonjs/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js +307 -0
- package/lib/commonjs/ui/screens/PrivacySettingsScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/ProfileScreen.js +1 -7
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js +205 -0
- package/lib/commonjs/ui/screens/SavesCollectionsScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js +239 -0
- package/lib/commonjs/ui/screens/SearchSettingsScreen.js.map +1 -0
- package/lib/commonjs/ui/screens/SignInScreen.js +14 -29
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/utils/asyncUtils.js +1 -0
- package/lib/commonjs/utils/asyncUtils.js.map +1 -1
- package/lib/commonjs/utils/cache.js +4 -4
- package/lib/commonjs/utils/cache.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -6
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/core/HttpClient.js +1 -1
- package/lib/module/core/HttpClient.js.map +1 -1
- package/lib/module/core/OxyServices.js +82 -8
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/i18n/locales/en-US.json +222 -6
- package/lib/module/lib/sonner.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +24 -22
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +40 -17
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/navigation/routes.js +36 -1
- package/lib/module/ui/navigation/routes.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +151 -6
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +475 -319
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountVerificationScreen.js +212 -0
- package/lib/module/ui/screens/AccountVerificationScreen.js.map +1 -0
- package/lib/module/ui/screens/FileManagementScreen.js +913 -212
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/HelpSupportScreen.js +126 -0
- package/lib/module/ui/screens/HelpSupportScreen.js.map +1 -0
- package/lib/module/ui/screens/HistoryViewScreen.js +253 -0
- package/lib/module/ui/screens/HistoryViewScreen.js.map +1 -0
- package/lib/module/ui/screens/LegalDocumentsScreen.js +206 -0
- package/lib/module/ui/screens/LegalDocumentsScreen.js.map +1 -0
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js +0 -1
- package/lib/module/ui/screens/PremiumSubscriptionScreen.js.map +1 -1
- package/lib/module/ui/screens/PrivacySettingsScreen.js +302 -0
- package/lib/module/ui/screens/PrivacySettingsScreen.js.map +1 -0
- package/lib/module/ui/screens/ProfileScreen.js +1 -7
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SavesCollectionsScreen.js +200 -0
- package/lib/module/ui/screens/SavesCollectionsScreen.js.map +1 -0
- package/lib/module/ui/screens/SearchSettingsScreen.js +234 -0
- package/lib/module/ui/screens/SearchSettingsScreen.js.map +1 -0
- package/lib/module/ui/screens/SignInScreen.js +14 -29
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/utils/asyncUtils.js +1 -0
- package/lib/module/utils/asyncUtils.js.map +1 -1
- package/lib/module/utils/cache.js +3 -3
- package/lib/module/utils/cache.js.map +1 -1
- package/lib/module/utils/index.js +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/core/OxyServices.d.ts +30 -6
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/lib/sonner.d.ts +1 -0
- package/lib/typescript/lib/sonner.d.ts.map +1 -1
- package/lib/typescript/types/expo-document-picker.d.ts +36 -0
- package/lib/typescript/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/navigation/routes.d.ts +1 -1
- package/lib/typescript/ui/navigation/routes.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/AccountVerificationScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/AccountVerificationScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/FileManagementScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/HelpSupportScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/HelpSupportScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/HistoryViewScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/HistoryViewScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/LegalDocumentsScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/LegalDocumentsScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/PremiumSubscriptionScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/PrivacySettingsScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/ProfileScreen.d.ts.map +1 -1
- package/lib/typescript/ui/screens/SavesCollectionsScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/SavesCollectionsScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/SearchSettingsScreen.d.ts +5 -0
- package/lib/typescript/ui/screens/SearchSettingsScreen.d.ts.map +1 -0
- package/lib/typescript/ui/screens/SignInScreen.d.ts.map +1 -1
- package/lib/typescript/utils/asyncUtils.d.ts.map +1 -1
- package/lib/typescript/utils/cache.d.ts +3 -3
- package/lib/typescript/utils/cache.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +1 -1
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/HttpClient.ts +1 -1
- package/src/core/OxyServices.ts +80 -8
- package/src/i18n/locales/en-US.json +222 -6
- package/src/lib/sonner.ts +1 -0
- package/src/types/expo-document-picker.d.ts +36 -0
- package/src/ui/components/GroupedItem.tsx +23 -21
- package/src/ui/components/OxyProvider.tsx +33 -11
- package/src/ui/navigation/routes.ts +42 -0
- package/src/ui/screens/AccountOverviewScreen.tsx +175 -5
- package/src/ui/screens/AccountSettingsScreen.tsx +521 -360
- package/src/ui/screens/AccountVerificationScreen.tsx +235 -0
- package/src/ui/screens/FileManagementScreen.tsx +934 -208
- package/src/ui/screens/HelpSupportScreen.tsx +143 -0
- package/src/ui/screens/HistoryViewScreen.tsx +280 -0
- package/src/ui/screens/LegalDocumentsScreen.tsx +220 -0
- package/src/ui/screens/PremiumSubscriptionScreen.tsx +0 -1
- package/src/ui/screens/PrivacySettingsScreen.tsx +332 -0
- package/src/ui/screens/ProfileScreen.tsx +1 -8
- package/src/ui/screens/SavesCollectionsScreen.tsx +222 -0
- package/src/ui/screens/SearchSettingsScreen.tsx +219 -0
- package/src/ui/screens/SignInScreen.tsx +19 -35
- package/src/utils/asyncUtils.ts +1 -0
- package/src/utils/cache.ts +3 -3
- package/src/utils/index.ts +1 -1
- package/lib/commonjs/ui/components/StepBasedScreen.README.md +0 -337
- package/lib/commonjs/ui/components/internal/TextField.md +0 -436
- package/lib/commonjs/ui/styles/FONTS.md +0 -126
- package/lib/module/ui/components/StepBasedScreen.README.md +0 -337
- package/lib/module/ui/components/internal/TextField.md +0 -436
- package/lib/module/ui/styles/FONTS.md +0 -126
- package/src/ui/components/StepBasedScreen.README.md +0 -337
- package/src/ui/components/internal/TextField.md +0 -436
- package/src/ui/styles/FONTS.md +0 -126
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo, useEffect } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
TouchableOpacity,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
ScrollView,
|
|
8
|
+
Switch,
|
|
9
|
+
ActivityIndicator,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import type { BaseScreenProps } from '../navigation/types';
|
|
12
|
+
import { useOxy } from '../context/OxyContext';
|
|
13
|
+
import { toast } from '../../lib/sonner';
|
|
14
|
+
import { Header, Section, GroupedSection } from '../components';
|
|
15
|
+
import { useI18n } from '../hooks/useI18n';
|
|
16
|
+
|
|
17
|
+
const SearchSettingsScreen: React.FC<BaseScreenProps> = ({
|
|
18
|
+
onClose,
|
|
19
|
+
theme,
|
|
20
|
+
goBack,
|
|
21
|
+
}) => {
|
|
22
|
+
const { oxyServices, user } = useOxy();
|
|
23
|
+
const { t } = useI18n();
|
|
24
|
+
const [safeSearch, setSafeSearch] = useState(false);
|
|
25
|
+
const [searchPersonalization, setSearchPersonalization] = useState(true);
|
|
26
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
27
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
28
|
+
|
|
29
|
+
// Load settings
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const loadSettings = async () => {
|
|
32
|
+
try {
|
|
33
|
+
setIsLoading(true);
|
|
34
|
+
if (user?.id && oxyServices) {
|
|
35
|
+
// Load from user's privacy settings
|
|
36
|
+
const userData = await oxyServices.getCurrentUser();
|
|
37
|
+
const privacySettings = (userData as any)?.privacySettings || {};
|
|
38
|
+
|
|
39
|
+
// SafeSearch is typically stored in privacySettings.autoFilter or a separate field
|
|
40
|
+
setSafeSearch(privacySettings.autoFilter ?? false);
|
|
41
|
+
setSearchPersonalization(privacySettings.dataSharing ?? true);
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Failed to load search settings:', error);
|
|
45
|
+
} finally {
|
|
46
|
+
setIsLoading(false);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
loadSettings();
|
|
51
|
+
}, [user?.id, oxyServices]);
|
|
52
|
+
|
|
53
|
+
const handleSafeSearchToggle = useCallback(async (value: boolean) => {
|
|
54
|
+
try {
|
|
55
|
+
setIsSaving(true);
|
|
56
|
+
setSafeSearch(value);
|
|
57
|
+
|
|
58
|
+
if (user?.id && oxyServices) {
|
|
59
|
+
// Update privacy settings
|
|
60
|
+
await oxyServices.updateProfile({
|
|
61
|
+
privacySettings: {
|
|
62
|
+
autoFilter: value,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
toast.success(t('searchSettings.safeSearch.updated') || 'SafeSearch setting updated');
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('Failed to update SafeSearch:', error);
|
|
69
|
+
toast.error(t('searchSettings.safeSearch.error') || 'Failed to update SafeSearch');
|
|
70
|
+
setSafeSearch(!value); // Revert on error
|
|
71
|
+
} finally {
|
|
72
|
+
setIsSaving(false);
|
|
73
|
+
}
|
|
74
|
+
}, [user?.id, oxyServices, t]);
|
|
75
|
+
|
|
76
|
+
const handlePersonalizationToggle = useCallback(async (value: boolean) => {
|
|
77
|
+
try {
|
|
78
|
+
setIsSaving(true);
|
|
79
|
+
setSearchPersonalization(value);
|
|
80
|
+
|
|
81
|
+
if (user?.id && oxyServices) {
|
|
82
|
+
// Update privacy settings
|
|
83
|
+
await oxyServices.updateProfile({
|
|
84
|
+
privacySettings: {
|
|
85
|
+
dataSharing: value,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
toast.success(t('searchSettings.personalization.updated') || 'Search personalization updated');
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('Failed to update personalization:', error);
|
|
92
|
+
toast.error(t('searchSettings.personalization.error') || 'Failed to update personalization');
|
|
93
|
+
setSearchPersonalization(!value); // Revert on error
|
|
94
|
+
} finally {
|
|
95
|
+
setIsSaving(false);
|
|
96
|
+
}
|
|
97
|
+
}, [user?.id, oxyServices, t]);
|
|
98
|
+
|
|
99
|
+
const themeStyles = useMemo(() => {
|
|
100
|
+
const isDarkTheme = theme === 'dark';
|
|
101
|
+
return {
|
|
102
|
+
textColor: isDarkTheme ? '#FFFFFF' : '#000000',
|
|
103
|
+
backgroundColor: isDarkTheme ? '#121212' : '#FFFFFF',
|
|
104
|
+
secondaryBackgroundColor: isDarkTheme ? '#222222' : '#F5F5F5',
|
|
105
|
+
borderColor: isDarkTheme ? '#444444' : '#E0E0E0',
|
|
106
|
+
};
|
|
107
|
+
}, [theme]);
|
|
108
|
+
|
|
109
|
+
if (isLoading) {
|
|
110
|
+
return (
|
|
111
|
+
<View style={[styles.container, { backgroundColor: themeStyles.backgroundColor }]}>
|
|
112
|
+
<Header
|
|
113
|
+
title={t('searchSettings.title') || 'Search Settings'}
|
|
114
|
+
theme={theme}
|
|
115
|
+
onBack={goBack || onClose}
|
|
116
|
+
variant="minimal"
|
|
117
|
+
elevation="subtle"
|
|
118
|
+
/>
|
|
119
|
+
<View style={styles.loadingContainer}>
|
|
120
|
+
<ActivityIndicator size="large" color={themeStyles.textColor} />
|
|
121
|
+
</View>
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<View style={[styles.container, { backgroundColor: themeStyles.backgroundColor }]}>
|
|
128
|
+
<Header
|
|
129
|
+
title={t('searchSettings.title') || 'Search Settings'}
|
|
130
|
+
theme={theme}
|
|
131
|
+
onBack={goBack || onClose}
|
|
132
|
+
variant="minimal"
|
|
133
|
+
elevation="subtle"
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
<ScrollView style={styles.content}>
|
|
137
|
+
{/* SafeSearch */}
|
|
138
|
+
<Section title={t('searchSettings.safeSearch.title') || 'SafeSearch'} theme={theme} isFirst={true}>
|
|
139
|
+
<View style={[styles.settingRow, { borderBottomColor: themeStyles.borderColor }]}>
|
|
140
|
+
<View style={styles.settingInfo}>
|
|
141
|
+
<Text style={[styles.settingTitle, { color: themeStyles.textColor }]}>
|
|
142
|
+
{t('searchSettings.safeSearch.label') || 'Enable SafeSearch'}
|
|
143
|
+
</Text>
|
|
144
|
+
<Text style={[styles.settingDescription, { color: themeStyles.textColor }]}>
|
|
145
|
+
{t('searchSettings.safeSearch.description') || 'Filter out explicit content from search results'}
|
|
146
|
+
</Text>
|
|
147
|
+
</View>
|
|
148
|
+
<Switch
|
|
149
|
+
value={safeSearch}
|
|
150
|
+
onValueChange={handleSafeSearchToggle}
|
|
151
|
+
disabled={isSaving}
|
|
152
|
+
trackColor={{ false: '#767577', true: '#d169e5' }}
|
|
153
|
+
thumbColor={safeSearch ? '#fff' : '#f4f3f4'}
|
|
154
|
+
/>
|
|
155
|
+
</View>
|
|
156
|
+
</Section>
|
|
157
|
+
|
|
158
|
+
{/* Search Personalization */}
|
|
159
|
+
<Section title={t('searchSettings.personalization.title') || 'Search Personalization'} theme={theme}>
|
|
160
|
+
<View style={[styles.settingRow, { borderBottomColor: themeStyles.borderColor }]}>
|
|
161
|
+
<View style={styles.settingInfo}>
|
|
162
|
+
<Text style={[styles.settingTitle, { color: themeStyles.textColor }]}>
|
|
163
|
+
{t('searchSettings.personalization.label') || 'Personalized Search'}
|
|
164
|
+
</Text>
|
|
165
|
+
<Text style={[styles.settingDescription, { color: themeStyles.textColor }]}>
|
|
166
|
+
{t('searchSettings.personalization.description') || 'Use your activity to improve search results'}
|
|
167
|
+
</Text>
|
|
168
|
+
</View>
|
|
169
|
+
<Switch
|
|
170
|
+
value={searchPersonalization}
|
|
171
|
+
onValueChange={handlePersonalizationToggle}
|
|
172
|
+
disabled={isSaving}
|
|
173
|
+
trackColor={{ false: '#767577', true: '#d169e5' }}
|
|
174
|
+
thumbColor={searchPersonalization ? '#fff' : '#f4f3f4'}
|
|
175
|
+
/>
|
|
176
|
+
</View>
|
|
177
|
+
</Section>
|
|
178
|
+
</ScrollView>
|
|
179
|
+
</View>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const styles = StyleSheet.create({
|
|
184
|
+
container: {
|
|
185
|
+
flex: 1,
|
|
186
|
+
},
|
|
187
|
+
content: {
|
|
188
|
+
flex: 1,
|
|
189
|
+
padding: 16,
|
|
190
|
+
},
|
|
191
|
+
loadingContainer: {
|
|
192
|
+
flex: 1,
|
|
193
|
+
alignItems: 'center',
|
|
194
|
+
justifyContent: 'center',
|
|
195
|
+
},
|
|
196
|
+
settingRow: {
|
|
197
|
+
flexDirection: 'row',
|
|
198
|
+
justifyContent: 'space-between',
|
|
199
|
+
alignItems: 'center',
|
|
200
|
+
paddingVertical: 16,
|
|
201
|
+
borderBottomWidth: 1,
|
|
202
|
+
},
|
|
203
|
+
settingInfo: {
|
|
204
|
+
flex: 1,
|
|
205
|
+
marginRight: 16,
|
|
206
|
+
},
|
|
207
|
+
settingTitle: {
|
|
208
|
+
fontSize: 16,
|
|
209
|
+
fontWeight: '500',
|
|
210
|
+
marginBottom: 4,
|
|
211
|
+
},
|
|
212
|
+
settingDescription: {
|
|
213
|
+
fontSize: 14,
|
|
214
|
+
opacity: 0.7,
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
export default React.memo(SearchSettingsScreen);
|
|
219
|
+
|
|
@@ -42,10 +42,7 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
42
42
|
|
|
43
43
|
// Username validation using core services with caching
|
|
44
44
|
const validateUsername = useCallback(async (usernameToValidate: string) => {
|
|
45
|
-
if (__DEV__) console.log('🔍 Validating username:', usernameToValidate);
|
|
46
|
-
|
|
47
45
|
if (!usernameToValidate || usernameToValidate.length < 3) {
|
|
48
|
-
if (__DEV__) console.log('❌ Username too short');
|
|
49
46
|
setValidationStatus('invalid');
|
|
50
47
|
setErrorMessage('Username must be at least 3 characters.');
|
|
51
48
|
return false;
|
|
@@ -53,7 +50,7 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
53
50
|
|
|
54
51
|
// Safety check for oxyServices
|
|
55
52
|
if (!oxyServices || typeof oxyServices.getProfileByUsername !== 'function') {
|
|
56
|
-
console.error('
|
|
53
|
+
console.error('oxyServices not available or getProfileByUsername not found');
|
|
57
54
|
setValidationStatus('invalid');
|
|
58
55
|
setErrorMessage('Service unavailable. Please try again.');
|
|
59
56
|
return false;
|
|
@@ -62,62 +59,51 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
62
59
|
const offlineDetected = typeof navigator !== 'undefined' && navigator.onLine === false;
|
|
63
60
|
|
|
64
61
|
if (offlineDetected) {
|
|
65
|
-
if (__DEV__) console.log('⚠️ Offline detected, skipping username validation');
|
|
66
62
|
setValidationStatus('invalid');
|
|
67
63
|
setErrorMessage('No connection. Check your internet connection and try again.');
|
|
68
64
|
return false;
|
|
69
65
|
}
|
|
70
66
|
|
|
71
|
-
if (__DEV__) console.log('🔄 Validating username with API...');
|
|
72
67
|
setIsValidating(true);
|
|
73
68
|
setValidationStatus('validating');
|
|
74
69
|
|
|
75
70
|
try {
|
|
76
71
|
// Check if username exists
|
|
77
72
|
const profile = await oxyServices.getProfileByUsername(usernameToValidate);
|
|
78
|
-
if (__DEV__) console.log('📋 Profile response:', profile);
|
|
79
73
|
|
|
80
|
-
|
|
74
|
+
// Handle case where profile might be wrapped in a data property (defensive check)
|
|
75
|
+
const userProfile = (profile as any)?.data || profile;
|
|
76
|
+
|
|
77
|
+
if (userProfile?.username) {
|
|
81
78
|
const profileData = {
|
|
82
|
-
displayName:
|
|
83
|
-
name:
|
|
84
|
-
avatar:
|
|
85
|
-
id:
|
|
79
|
+
displayName: userProfile.name?.full || userProfile.name?.first || userProfile.username,
|
|
80
|
+
name: userProfile.username,
|
|
81
|
+
avatar: userProfile.avatar,
|
|
82
|
+
id: userProfile.id
|
|
86
83
|
};
|
|
87
84
|
|
|
88
|
-
if (__DEV__) console.log('✅ Username is valid:', profileData);
|
|
89
85
|
setUserProfile(profileData);
|
|
90
|
-
|
|
86
|
+
|
|
91
87
|
// Check if this account is already signed in
|
|
92
|
-
const profileUserId =
|
|
88
|
+
const profileUserId = userProfile.id?.toString();
|
|
93
89
|
const existing = sessions?.find(s => {
|
|
94
90
|
const sessionUserId = s.userId?.toString();
|
|
95
91
|
return sessionUserId === profileUserId;
|
|
96
92
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
setExistingSession(existing);
|
|
100
|
-
if (__DEV__) console.log('✅ Account already signed in:', existing);
|
|
101
|
-
} else {
|
|
102
|
-
setExistingSession(null);
|
|
103
|
-
}
|
|
104
|
-
|
|
93
|
+
|
|
94
|
+
setExistingSession(existing || null);
|
|
105
95
|
setValidationStatus('valid');
|
|
106
96
|
setErrorMessage('');
|
|
107
97
|
|
|
108
98
|
return true;
|
|
109
|
-
} else {
|
|
110
|
-
if (__DEV__) console.log('❌ Username not found');
|
|
111
|
-
setValidationStatus('invalid');
|
|
112
|
-
setErrorMessage('Username not found.');
|
|
113
|
-
return false;
|
|
114
99
|
}
|
|
115
|
-
} catch (error: any) {
|
|
116
|
-
if (__DEV__) console.log('🚨 Validation error:', error);
|
|
117
100
|
|
|
101
|
+
setValidationStatus('invalid');
|
|
102
|
+
setErrorMessage('Username not found.');
|
|
103
|
+
return false;
|
|
104
|
+
} catch (error: any) {
|
|
118
105
|
// If user not found (404), username doesn't exist
|
|
119
106
|
if (error?.status === 404 || error?.code === 'USER_NOT_FOUND') {
|
|
120
|
-
console.log('❌ Username not found (404)');
|
|
121
107
|
setValidationStatus('invalid');
|
|
122
108
|
setErrorMessage('Username not found.');
|
|
123
109
|
return false;
|
|
@@ -147,7 +133,6 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
147
133
|
|
|
148
134
|
// Input change handlers
|
|
149
135
|
const handleUsernameChange = useCallback((text: string) => {
|
|
150
|
-
console.log('🔄 SignInScreen handleUsernameChange called:', text);
|
|
151
136
|
setUsername(text);
|
|
152
137
|
if (errorMessage) setErrorMessage('');
|
|
153
138
|
setValidationStatus('idle');
|
|
@@ -183,7 +168,7 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
183
168
|
|
|
184
169
|
const handleContinueWithExistingAccount = useCallback(async () => {
|
|
185
170
|
if (!existingSession) return;
|
|
186
|
-
|
|
171
|
+
|
|
187
172
|
try {
|
|
188
173
|
setErrorMessage('');
|
|
189
174
|
await switchSession(existingSession.sessionId);
|
|
@@ -206,7 +191,7 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
206
191
|
setErrorMessage('Please enter a valid username first.');
|
|
207
192
|
return;
|
|
208
193
|
}
|
|
209
|
-
|
|
194
|
+
|
|
210
195
|
try {
|
|
211
196
|
setErrorMessage('');
|
|
212
197
|
const user = await login(username, password);
|
|
@@ -238,7 +223,6 @@ const SignInScreen: React.FC<BaseScreenProps> = ({
|
|
|
238
223
|
const handleComplete = useCallback(async (stepData: any[]) => {
|
|
239
224
|
// The sign-in is handled by the password step component
|
|
240
225
|
// This callback is here for interface compatibility
|
|
241
|
-
if (__DEV__) console.log('Sign-in flow completed');
|
|
242
226
|
}, []);
|
|
243
227
|
|
|
244
228
|
// Step data for the reusable component
|
package/src/utils/asyncUtils.ts
CHANGED
|
@@ -204,6 +204,7 @@ export async function withTimeout<T>(
|
|
|
204
204
|
export function createAsyncCache<T>(
|
|
205
205
|
ttl: number = 5 * 60 * 1000 // 5 minutes default
|
|
206
206
|
) {
|
|
207
|
+
// Re-export from centralized cache utility
|
|
207
208
|
const cache = new TTLCache<T>(ttl);
|
|
208
209
|
registerCacheForCleanup(cache);
|
|
209
210
|
|
package/src/utils/cache.ts
CHANGED
|
@@ -251,10 +251,10 @@ export function unregisterCacheFromCleanup(cache: TTLCache<any>): void {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/**
|
|
254
|
-
* Stop all
|
|
255
|
-
*
|
|
254
|
+
* Stop all cleanup intervals (useful for testing)
|
|
255
|
+
* This will clear the interval and unregister all caches
|
|
256
256
|
*/
|
|
257
|
-
export function
|
|
257
|
+
export function stopAllCleanupIntervals(): void {
|
|
258
258
|
if (cleanupInterval) {
|
|
259
259
|
clearInterval(cleanupInterval);
|
|
260
260
|
cleanupInterval = null;
|
package/src/utils/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type { DeviceFingerprint, StoredDeviceInfo } from './deviceManager';
|
|
|
5
5
|
export { RequestDeduplicator, RequestQueue, SimpleLogger } from './requestUtils';
|
|
6
6
|
|
|
7
7
|
// Cache utilities
|
|
8
|
-
export { TTLCache, createCache, registerCacheForCleanup, unregisterCacheFromCleanup
|
|
8
|
+
export { TTLCache, createCache, registerCacheForCleanup, unregisterCacheFromCleanup } from './cache';
|
|
9
9
|
export type { CacheStats } from './cache';
|
|
10
10
|
|
|
11
11
|
// Session utilities
|