@oxyhq/services 5.16.1 → 5.16.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/lib/commonjs/core/mixins/OxyServices.user.js +14 -13
- package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/commonjs/crypto/keyManager.js +164 -3
- package/lib/commonjs/crypto/keyManager.js.map +1 -1
- package/lib/commonjs/crypto/signatureService.js +26 -0
- package/lib/commonjs/crypto/signatureService.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedSection.js +1 -1
- package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +71 -24
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js +1 -4
- package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +175 -4
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js +148 -49
- package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/commonjs/ui/context/hooks/useSessionManagement.js +22 -2
- package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/index.js +28 -0
- package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -0
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +314 -0
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -0
- package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js +193 -0
- package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js.map +1 -0
- package/lib/commonjs/ui/hooks/queries/index.js +39 -0
- package/lib/commonjs/ui/hooks/queries/index.js.map +1 -0
- package/lib/commonjs/ui/hooks/queries/queryKeys.js +85 -0
- package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -0
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +145 -0
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -0
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +138 -0
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -0
- package/lib/commonjs/ui/hooks/queryClient.js +117 -0
- package/lib/commonjs/ui/hooks/queryClient.js.map +1 -0
- package/lib/commonjs/ui/hooks/useIdentityMutations.js +111 -0
- package/lib/commonjs/ui/hooks/useIdentityMutations.js.map +1 -0
- package/lib/commonjs/ui/hooks/useProfileEditing.js +42 -58
- package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/commonjs/ui/hooks/useQueryClient.js +20 -0
- package/lib/commonjs/ui/hooks/useQueryClient.js.map +1 -0
- package/lib/commonjs/ui/hooks/useSessionManagement.js +22 -2
- package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js +43 -42
- package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +63 -58
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +6 -6
- package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/accountStore.js +57 -42
- package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
- package/lib/commonjs/ui/stores/authStore.js +4 -25
- package/lib/commonjs/ui/stores/authStore.js.map +1 -1
- package/lib/module/core/mixins/OxyServices.user.js +14 -13
- package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
- package/lib/module/crypto/keyManager.js +164 -3
- package/lib/module/crypto/keyManager.js.map +1 -1
- package/lib/module/crypto/signatureService.js +26 -0
- package/lib/module/crypto/signatureService.js.map +1 -1
- package/lib/module/ui/components/GroupedSection.js +1 -1
- package/lib/module/ui/components/GroupedSection.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +72 -25
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/profile/EditDisplayNameModal.js +1 -4
- package/lib/module/ui/components/profile/EditDisplayNameModal.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +174 -4
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/context/hooks/useAuthOperations.js +148 -49
- package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
- package/lib/module/ui/context/hooks/useSessionManagement.js +22 -2
- package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/hooks/mutations/index.js +6 -0
- package/lib/module/ui/hooks/mutations/index.js.map +1 -0
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +308 -0
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -0
- package/lib/module/ui/hooks/mutations/useServicesMutations.js +185 -0
- package/lib/module/ui/hooks/mutations/useServicesMutations.js.map +1 -0
- package/lib/module/ui/hooks/queries/index.js +7 -0
- package/lib/module/ui/hooks/queries/index.js.map +1 -0
- package/lib/module/ui/hooks/queries/queryKeys.js +78 -0
- package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -0
- package/lib/module/ui/hooks/queries/useAccountQueries.js +136 -0
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -0
- package/lib/module/ui/hooks/queries/useServicesQueries.js +130 -0
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -0
- package/lib/module/ui/hooks/queryClient.js +110 -0
- package/lib/module/ui/hooks/queryClient.js.map +1 -0
- package/lib/module/ui/hooks/useIdentityMutations.js +105 -0
- package/lib/module/ui/hooks/useIdentityMutations.js.map +1 -0
- package/lib/module/ui/hooks/useProfileEditing.js +43 -59
- package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
- package/lib/module/ui/hooks/useQueryClient.js +15 -0
- package/lib/module/ui/hooks/useQueryClient.js.map +1 -0
- package/lib/module/ui/hooks/useSessionManagement.js +22 -2
- package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
- package/lib/module/ui/screens/AccountOverviewScreen.js +43 -42
- package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +63 -58
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/WelcomeNewUserScreen.js +6 -6
- package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
- package/lib/module/ui/stores/accountStore.js +57 -42
- package/lib/module/ui/stores/accountStore.js.map +1 -1
- package/lib/module/ui/stores/authStore.js +4 -25
- package/lib/module/ui/stores/authStore.js.map +1 -1
- package/lib/typescript/core/mixins/OxyServices.user.d.ts +4 -5
- package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
- package/lib/typescript/core/mixins/index.d.ts +0 -1
- package/lib/typescript/core/mixins/index.d.ts.map +1 -1
- package/lib/typescript/crypto/keyManager.d.ts +19 -2
- package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/crypto/signatureService.d.ts +5 -0
- package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
- package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts +4 -0
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +3 -1
- package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/mutations/index.d.ts +3 -0
- package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +25 -0
- package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +23 -0
- package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/queries/index.d.ts +4 -0
- package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +56 -0
- package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +41 -0
- package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts +34 -0
- package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/queryClient.d.ts +19 -0
- package/lib/typescript/ui/hooks/queryClient.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts +29 -0
- package/lib/typescript/ui/hooks/useIdentityMutations.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
- package/lib/typescript/ui/hooks/useQueryClient.d.ts +7 -0
- package/lib/typescript/ui/hooks/useQueryClient.d.ts.map +1 -0
- package/lib/typescript/ui/hooks/useSessionManagement.d.ts +3 -1
- package/lib/typescript/ui/hooks/useSessionManagement.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/WelcomeNewUserScreen.d.ts.map +1 -1
- package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
- package/lib/typescript/ui/stores/authStore.d.ts +0 -4
- package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/core/mixins/OxyServices.user.ts +17 -10
- package/src/crypto/keyManager.ts +177 -2
- package/src/crypto/signatureService.ts +30 -0
- package/src/ui/components/GroupedSection.tsx +1 -1
- package/src/ui/components/OxyProvider.tsx +91 -37
- package/src/ui/components/profile/EditDisplayNameModal.tsx +1 -3
- package/src/ui/context/OxyContext.tsx +185 -2
- package/src/ui/context/hooks/useAuthOperations.ts +171 -58
- package/src/ui/context/hooks/useSessionManagement.ts +24 -1
- package/src/ui/hooks/mutations/index.ts +4 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +277 -0
- package/src/ui/hooks/mutations/useServicesMutations.ts +164 -0
- package/src/ui/hooks/queries/index.ts +5 -0
- package/src/ui/hooks/queries/queryKeys.ts +73 -0
- package/src/ui/hooks/queries/useAccountQueries.ts +126 -0
- package/src/ui/hooks/queries/useServicesQueries.ts +121 -0
- package/src/ui/hooks/queryClient.ts +112 -0
- package/src/ui/hooks/useIdentityMutations.ts +115 -0
- package/src/ui/hooks/useProfileEditing.ts +46 -60
- package/src/ui/hooks/useQueryClient.ts +17 -0
- package/src/ui/hooks/useSessionManagement.ts +24 -1
- package/src/ui/screens/AccountOverviewScreen.tsx +38 -46
- package/src/ui/screens/AccountSettingsScreen.tsx +54 -54
- package/src/ui/screens/WelcomeNewUserScreen.tsx +13 -12
- package/src/ui/stores/accountStore.ts +54 -43
- package/src/ui/stores/authStore.ts +3 -17
|
@@ -26,6 +26,8 @@ import { EditLinksModal } from '../components/profile/EditLinksModal';
|
|
|
26
26
|
import { getDisplayName } from '../utils/user-utils';
|
|
27
27
|
import { TTLCache, registerCacheForCleanup } from '../../utils/cache';
|
|
28
28
|
import { useOxy } from '../context/OxyContext';
|
|
29
|
+
import { useCurrentUser } from '../hooks/queries/useAccountQueries';
|
|
30
|
+
import { useUpdateProfile, useUploadAvatar } from '../hooks/mutations/useAccountMutations';
|
|
29
31
|
import { SECTION_GAP_LARGE, COMPONENT_GAP, HEADER_PADDING_TOP_SETTINGS, createScreenContentStyle } from '../constants/spacing';
|
|
30
32
|
|
|
31
33
|
// Caches for link metadata and location searches
|
|
@@ -45,9 +47,7 @@ const AccountSettingsScreen = ({
|
|
|
45
47
|
}) => {
|
|
46
48
|
// Use useOxy() hook for OxyContext values
|
|
47
49
|
const {
|
|
48
|
-
user: userFromContext,
|
|
49
50
|
oxyServices,
|
|
50
|
-
isLoading: authLoading,
|
|
51
51
|
isAuthenticated,
|
|
52
52
|
activeSessionId
|
|
53
53
|
} = useOxy();
|
|
@@ -55,12 +55,23 @@ const AccountSettingsScreen = ({
|
|
|
55
55
|
t
|
|
56
56
|
} = useI18n();
|
|
57
57
|
const normalizedTheme = normalizeTheme(theme);
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
const
|
|
58
|
+
|
|
59
|
+
// Use TanStack Query for user data
|
|
60
|
+
const {
|
|
61
|
+
data: user,
|
|
62
|
+
isLoading: userLoading
|
|
63
|
+
} = useCurrentUser({
|
|
64
|
+
enabled: isAuthenticated
|
|
65
|
+
});
|
|
66
|
+
const updateProfileMutation = useUpdateProfile();
|
|
67
|
+
const uploadAvatarMutation = useUploadAvatar();
|
|
68
|
+
|
|
69
|
+
// Fallback to store for backward compatibility
|
|
70
|
+
const userFromStore = useAuthStore(state => state.user);
|
|
71
|
+
const finalUser = user || userFromStore;
|
|
61
72
|
const [isLoading, setIsLoading] = useState(false);
|
|
62
|
-
const
|
|
63
|
-
const
|
|
73
|
+
const isSaving = updateProfileMutation.isPending;
|
|
74
|
+
const isUpdatingAvatar = uploadAvatarMutation.isPending;
|
|
64
75
|
const [optimisticAvatarId, setOptimisticAvatarId] = useState(null);
|
|
65
76
|
const scrollViewRef = useRef(null);
|
|
66
77
|
const avatarSectionRef = useRef(null);
|
|
@@ -159,9 +170,9 @@ const AccountSettingsScreen = ({
|
|
|
159
170
|
|
|
160
171
|
// Load user data - only reset fields when user actually changes (not just avatar)
|
|
161
172
|
useEffect(() => {
|
|
162
|
-
if (
|
|
163
|
-
const currentUserId =
|
|
164
|
-
const currentAvatar = typeof
|
|
173
|
+
if (finalUser) {
|
|
174
|
+
const currentUserId = finalUser.id;
|
|
175
|
+
const currentAvatar = typeof finalUser.avatar === 'string' ? finalUser.avatar : '';
|
|
165
176
|
const isNewUser = previousUserIdRef.current !== currentUserId;
|
|
166
177
|
const isAvatarOnlyUpdate = !isNewUser && previousUserIdRef.current === currentUserId && previousAvatarRef.current !== currentAvatar && previousAvatarRef.current !== null;
|
|
167
178
|
const shouldInitialize = !isInitializedRef.current || isNewUser;
|
|
@@ -169,28 +180,28 @@ const AccountSettingsScreen = ({
|
|
|
169
180
|
// Only reset all fields if it's a new user or first load
|
|
170
181
|
// Skip reset if it's just an avatar update
|
|
171
182
|
if (shouldInitialize && !isAvatarOnlyUpdate) {
|
|
172
|
-
const userDisplayName = typeof
|
|
173
|
-
const userLastName = typeof
|
|
183
|
+
const userDisplayName = typeof finalUser.name === 'string' ? finalUser.name : finalUser.name?.first || finalUser.name?.full || '';
|
|
184
|
+
const userLastName = typeof finalUser.name === 'object' ? finalUser.name?.last || '' : '';
|
|
174
185
|
setDisplayName(userDisplayName);
|
|
175
186
|
setLastName(userLastName);
|
|
176
|
-
setUsername(
|
|
177
|
-
setEmail(
|
|
178
|
-
setBio(
|
|
179
|
-
setLocation(
|
|
187
|
+
setUsername(finalUser.username || '');
|
|
188
|
+
setEmail(finalUser.email || '');
|
|
189
|
+
setBio(finalUser.bio || '');
|
|
190
|
+
setLocation(finalUser.location || '');
|
|
180
191
|
|
|
181
192
|
// Handle locations - convert single location to array format
|
|
182
|
-
if (
|
|
183
|
-
setLocations(
|
|
193
|
+
if (finalUser.locations && Array.isArray(finalUser.locations)) {
|
|
194
|
+
setLocations(finalUser.locations.map((loc, index) => ({
|
|
184
195
|
id: loc.id || `existing-${index}`,
|
|
185
196
|
name: loc.name,
|
|
186
197
|
label: loc.label,
|
|
187
198
|
coordinates: loc.coordinates
|
|
188
199
|
})));
|
|
189
|
-
} else if (
|
|
200
|
+
} else if (finalUser.location) {
|
|
190
201
|
// Convert single location string to array format
|
|
191
202
|
setLocations([{
|
|
192
203
|
id: 'existing-0',
|
|
193
|
-
name:
|
|
204
|
+
name: finalUser.location,
|
|
194
205
|
label: 'Location'
|
|
195
206
|
}]);
|
|
196
207
|
} else {
|
|
@@ -198,16 +209,16 @@ const AccountSettingsScreen = ({
|
|
|
198
209
|
}
|
|
199
210
|
|
|
200
211
|
// Handle links - simple and direct like other fields
|
|
201
|
-
if (
|
|
202
|
-
const urls =
|
|
212
|
+
if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
|
|
213
|
+
const urls = finalUser.linksMetadata.map(l => l.url);
|
|
203
214
|
setLinks(urls);
|
|
204
|
-
const metadataWithIds =
|
|
215
|
+
const metadataWithIds = finalUser.linksMetadata.map((link, index) => ({
|
|
205
216
|
...link,
|
|
206
217
|
id: link.id || `existing-${index}`
|
|
207
218
|
}));
|
|
208
219
|
setLinksMetadata(metadataWithIds);
|
|
209
|
-
} else if (Array.isArray(
|
|
210
|
-
const simpleLinks =
|
|
220
|
+
} else if (Array.isArray(finalUser.links)) {
|
|
221
|
+
const simpleLinks = finalUser.links.map(l => typeof l === 'string' ? l : l.link).filter(Boolean);
|
|
211
222
|
setLinks(simpleLinks);
|
|
212
223
|
const linksWithMetadata = simpleLinks.map((url, index) => ({
|
|
213
224
|
url,
|
|
@@ -217,12 +228,12 @@ const AccountSettingsScreen = ({
|
|
|
217
228
|
id: `existing-${index}`
|
|
218
229
|
}));
|
|
219
230
|
setLinksMetadata(linksWithMetadata);
|
|
220
|
-
} else if (
|
|
221
|
-
setLinks([
|
|
231
|
+
} else if (finalUser.website) {
|
|
232
|
+
setLinks([finalUser.website]);
|
|
222
233
|
setLinksMetadata([{
|
|
223
|
-
url:
|
|
224
|
-
title:
|
|
225
|
-
description: `Link to ${
|
|
234
|
+
url: finalUser.website,
|
|
235
|
+
title: finalUser.website.replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
|
236
|
+
description: `Link to ${finalUser.website}`,
|
|
226
237
|
image: undefined,
|
|
227
238
|
id: 'existing-0'
|
|
228
239
|
}]);
|
|
@@ -250,7 +261,7 @@ const AccountSettingsScreen = ({
|
|
|
250
261
|
previousUserIdRef.current = currentUserId;
|
|
251
262
|
previousAvatarRef.current = currentAvatar;
|
|
252
263
|
}
|
|
253
|
-
}, [
|
|
264
|
+
}, [finalUser, avatarFileId, isUpdatingAvatar, optimisticAvatarId]);
|
|
254
265
|
|
|
255
266
|
// Set initial editing field if provided via props (e.g., from navigation)
|
|
256
267
|
// Use a ref to track if we've already set the initial field to avoid loops
|
|
@@ -307,47 +318,46 @@ const AccountSettingsScreen = ({
|
|
|
307
318
|
}, []);
|
|
308
319
|
const saveField = useCallback(async field => {
|
|
309
320
|
if (!field) return;
|
|
310
|
-
setIsSaving(true);
|
|
311
321
|
try {
|
|
312
322
|
switch (field) {
|
|
313
323
|
case 'displayName':
|
|
314
|
-
await
|
|
324
|
+
await updateProfileMutation.mutateAsync({
|
|
315
325
|
name: {
|
|
316
326
|
first: tempDisplayName,
|
|
317
327
|
last: tempLastName
|
|
318
328
|
}
|
|
319
|
-
}
|
|
329
|
+
});
|
|
320
330
|
setDisplayName(tempDisplayName);
|
|
321
331
|
setLastName(tempLastName);
|
|
322
332
|
break;
|
|
323
333
|
case 'username':
|
|
324
|
-
await
|
|
334
|
+
await updateProfileMutation.mutateAsync({
|
|
325
335
|
username: tempUsername
|
|
326
|
-
}
|
|
336
|
+
});
|
|
327
337
|
setUsername(tempUsername);
|
|
328
338
|
break;
|
|
329
339
|
case 'email':
|
|
330
|
-
await
|
|
340
|
+
await updateProfileMutation.mutateAsync({
|
|
331
341
|
email: tempEmail
|
|
332
|
-
}
|
|
342
|
+
});
|
|
333
343
|
setEmail(tempEmail);
|
|
334
344
|
break;
|
|
335
345
|
case 'bio':
|
|
336
|
-
await
|
|
346
|
+
await updateProfileMutation.mutateAsync({
|
|
337
347
|
bio: tempBio
|
|
338
|
-
}
|
|
348
|
+
});
|
|
339
349
|
setBio(tempBio);
|
|
340
350
|
break;
|
|
341
351
|
case 'location':
|
|
342
|
-
await
|
|
352
|
+
await updateProfileMutation.mutateAsync({
|
|
343
353
|
locations: tempLocations
|
|
344
|
-
}
|
|
354
|
+
});
|
|
345
355
|
setLocations(tempLocations);
|
|
346
356
|
break;
|
|
347
357
|
case 'links':
|
|
348
|
-
await
|
|
358
|
+
await updateProfileMutation.mutateAsync({
|
|
349
359
|
linksMetadata: tempLinksWithMetadata
|
|
350
|
-
}
|
|
360
|
+
});
|
|
351
361
|
setLinksMetadata(tempLinksWithMetadata);
|
|
352
362
|
setLinks(tempLinksWithMetadata.map(l => l.url));
|
|
353
363
|
break;
|
|
@@ -355,11 +365,9 @@ const AccountSettingsScreen = ({
|
|
|
355
365
|
setEditingField(null);
|
|
356
366
|
toast.success(t('editProfile.toasts.saved') || 'Saved');
|
|
357
367
|
} catch (error) {
|
|
358
|
-
|
|
359
|
-
} finally {
|
|
360
|
-
setIsSaving(false);
|
|
368
|
+
// Error is already handled by mutation's onError
|
|
361
369
|
}
|
|
362
|
-
}, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata,
|
|
370
|
+
}, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata, updateProfileMutation, t]);
|
|
363
371
|
|
|
364
372
|
// Helper to get current value for a field
|
|
365
373
|
const getFieldCurrentValue = useCallback(field => {
|
|
@@ -413,9 +421,8 @@ const AccountSettingsScreen = ({
|
|
|
413
421
|
}
|
|
414
422
|
}, [initialSection, sectionYPositions]);
|
|
415
423
|
const handleSave = async () => {
|
|
416
|
-
if (!
|
|
424
|
+
if (!finalUser) return;
|
|
417
425
|
try {
|
|
418
|
-
setIsSaving(true);
|
|
419
426
|
animateSaveButton(0.95); // Scale down slightly for animation
|
|
420
427
|
|
|
421
428
|
const updates = {
|
|
@@ -438,10 +445,10 @@ const AccountSettingsScreen = ({
|
|
|
438
445
|
}
|
|
439
446
|
|
|
440
447
|
// Handle avatar
|
|
441
|
-
if (avatarFileId !== (typeof
|
|
448
|
+
if (avatarFileId !== (typeof finalUser.avatar === 'string' ? finalUser.avatar : '')) {
|
|
442
449
|
updates.avatar = avatarFileId;
|
|
443
450
|
}
|
|
444
|
-
await
|
|
451
|
+
await updateProfileMutation.mutateAsync(updates);
|
|
445
452
|
toast.success(t('editProfile.toasts.profileUpdated') || 'Profile updated successfully');
|
|
446
453
|
animateSaveButton(1); // Scale back to normal
|
|
447
454
|
|
|
@@ -451,10 +458,8 @@ const AccountSettingsScreen = ({
|
|
|
451
458
|
goBack();
|
|
452
459
|
}
|
|
453
460
|
} catch (error) {
|
|
454
|
-
|
|
461
|
+
// Error is already handled by mutation's onError
|
|
455
462
|
animateSaveButton(1); // Scale back to normal on error
|
|
456
|
-
} finally {
|
|
457
|
-
setIsSaving(false);
|
|
458
463
|
}
|
|
459
464
|
};
|
|
460
465
|
const handleAvatarRemove = () => {
|
|
@@ -671,7 +676,7 @@ const AccountSettingsScreen = ({
|
|
|
671
676
|
};
|
|
672
677
|
|
|
673
678
|
// Memoize display name for avatar
|
|
674
|
-
const displayNameForAvatar = useMemo(() => getDisplayName(
|
|
679
|
+
const displayNameForAvatar = useMemo(() => getDisplayName(finalUser), [finalUser]);
|
|
675
680
|
|
|
676
681
|
// Legacy renderEditingField function (fallback)
|
|
677
682
|
const renderEditingField = type => {
|
|
@@ -1169,7 +1174,7 @@ const AccountSettingsScreen = ({
|
|
|
1169
1174
|
})
|
|
1170
1175
|
});
|
|
1171
1176
|
};
|
|
1172
|
-
if (
|
|
1177
|
+
if (userLoading || !isAuthenticated) {
|
|
1173
1178
|
return /*#__PURE__*/_jsx(View, {
|
|
1174
1179
|
style: [styles.container, {
|
|
1175
1180
|
backgroundColor: themeStyles.backgroundColor,
|
|
@@ -1467,7 +1472,7 @@ const AccountSettingsScreen = ({
|
|
|
1467
1472
|
title: t('editProfile.items.previewProfile.title') || 'Preview Profile',
|
|
1468
1473
|
subtitle: t('editProfile.items.previewProfile.subtitle') || 'See how your profile looks to others',
|
|
1469
1474
|
onPress: () => navigate?.('Profile', {
|
|
1470
|
-
userId:
|
|
1475
|
+
userId: finalUser?.id
|
|
1471
1476
|
})
|
|
1472
1477
|
}, {
|
|
1473
1478
|
id: 'privacy-settings',
|