@oxyhq/services 5.16.0 → 5.16.2
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.assets.js +15 -0
- package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
- 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/index.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 +177 -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.assets.js +15 -0
- package/lib/module/core/mixins/OxyServices.assets.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/index.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 +176 -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.assets.d.ts +7 -1
- package/lib/typescript/core/mixins/OxyServices.assets.d.ts.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 +1 -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/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/models/interfaces.d.ts +21 -0
- package/lib/typescript/models/interfaces.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 +6 -5
- package/src/core/mixins/OxyServices.assets.ts +16 -1
- 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/index.ts +4 -1
- package/src/models/interfaces.ts +23 -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
|
@@ -28,6 +28,8 @@ var _EditLinksModal = require("../components/profile/EditLinksModal");
|
|
|
28
28
|
var _userUtils = require("../utils/user-utils");
|
|
29
29
|
var _cache = require("../../utils/cache");
|
|
30
30
|
var _OxyContext = require("../context/OxyContext");
|
|
31
|
+
var _useAccountQueries = require("../hooks/queries/useAccountQueries");
|
|
32
|
+
var _useAccountMutations = require("../hooks/mutations/useAccountMutations");
|
|
31
33
|
var _spacing = require("../constants/spacing");
|
|
32
34
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
35
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -50,9 +52,7 @@ const AccountSettingsScreen = ({
|
|
|
50
52
|
}) => {
|
|
51
53
|
// Use useOxy() hook for OxyContext values
|
|
52
54
|
const {
|
|
53
|
-
user: userFromContext,
|
|
54
55
|
oxyServices,
|
|
55
|
-
isLoading: authLoading,
|
|
56
56
|
isAuthenticated,
|
|
57
57
|
activeSessionId
|
|
58
58
|
} = (0, _OxyContext.useOxy)();
|
|
@@ -60,12 +60,23 @@ const AccountSettingsScreen = ({
|
|
|
60
60
|
t
|
|
61
61
|
} = (0, _useI18n.useI18n)();
|
|
62
62
|
const normalizedTheme = (0, _themeUtils.normalizeTheme)(theme);
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
const
|
|
63
|
+
|
|
64
|
+
// Use TanStack Query for user data
|
|
65
|
+
const {
|
|
66
|
+
data: user,
|
|
67
|
+
isLoading: userLoading
|
|
68
|
+
} = (0, _useAccountQueries.useCurrentUser)({
|
|
69
|
+
enabled: isAuthenticated
|
|
70
|
+
});
|
|
71
|
+
const updateProfileMutation = (0, _useAccountMutations.useUpdateProfile)();
|
|
72
|
+
const uploadAvatarMutation = (0, _useAccountMutations.useUploadAvatar)();
|
|
73
|
+
|
|
74
|
+
// Fallback to store for backward compatibility
|
|
75
|
+
const userFromStore = (0, _authStore.useAuthStore)(state => state.user);
|
|
76
|
+
const finalUser = user || userFromStore;
|
|
66
77
|
const [isLoading, setIsLoading] = (0, _react.useState)(false);
|
|
67
|
-
const
|
|
68
|
-
const
|
|
78
|
+
const isSaving = updateProfileMutation.isPending;
|
|
79
|
+
const isUpdatingAvatar = uploadAvatarMutation.isPending;
|
|
69
80
|
const [optimisticAvatarId, setOptimisticAvatarId] = (0, _react.useState)(null);
|
|
70
81
|
const scrollViewRef = (0, _react.useRef)(null);
|
|
71
82
|
const avatarSectionRef = (0, _react.useRef)(null);
|
|
@@ -164,9 +175,9 @@ const AccountSettingsScreen = ({
|
|
|
164
175
|
|
|
165
176
|
// Load user data - only reset fields when user actually changes (not just avatar)
|
|
166
177
|
(0, _react.useEffect)(() => {
|
|
167
|
-
if (
|
|
168
|
-
const currentUserId =
|
|
169
|
-
const currentAvatar = typeof
|
|
178
|
+
if (finalUser) {
|
|
179
|
+
const currentUserId = finalUser.id;
|
|
180
|
+
const currentAvatar = typeof finalUser.avatar === 'string' ? finalUser.avatar : '';
|
|
170
181
|
const isNewUser = previousUserIdRef.current !== currentUserId;
|
|
171
182
|
const isAvatarOnlyUpdate = !isNewUser && previousUserIdRef.current === currentUserId && previousAvatarRef.current !== currentAvatar && previousAvatarRef.current !== null;
|
|
172
183
|
const shouldInitialize = !isInitializedRef.current || isNewUser;
|
|
@@ -174,28 +185,28 @@ const AccountSettingsScreen = ({
|
|
|
174
185
|
// Only reset all fields if it's a new user or first load
|
|
175
186
|
// Skip reset if it's just an avatar update
|
|
176
187
|
if (shouldInitialize && !isAvatarOnlyUpdate) {
|
|
177
|
-
const userDisplayName = typeof
|
|
178
|
-
const userLastName = typeof
|
|
188
|
+
const userDisplayName = typeof finalUser.name === 'string' ? finalUser.name : finalUser.name?.first || finalUser.name?.full || '';
|
|
189
|
+
const userLastName = typeof finalUser.name === 'object' ? finalUser.name?.last || '' : '';
|
|
179
190
|
setDisplayName(userDisplayName);
|
|
180
191
|
setLastName(userLastName);
|
|
181
|
-
setUsername(
|
|
182
|
-
setEmail(
|
|
183
|
-
setBio(
|
|
184
|
-
setLocation(
|
|
192
|
+
setUsername(finalUser.username || '');
|
|
193
|
+
setEmail(finalUser.email || '');
|
|
194
|
+
setBio(finalUser.bio || '');
|
|
195
|
+
setLocation(finalUser.location || '');
|
|
185
196
|
|
|
186
197
|
// Handle locations - convert single location to array format
|
|
187
|
-
if (
|
|
188
|
-
setLocations(
|
|
198
|
+
if (finalUser.locations && Array.isArray(finalUser.locations)) {
|
|
199
|
+
setLocations(finalUser.locations.map((loc, index) => ({
|
|
189
200
|
id: loc.id || `existing-${index}`,
|
|
190
201
|
name: loc.name,
|
|
191
202
|
label: loc.label,
|
|
192
203
|
coordinates: loc.coordinates
|
|
193
204
|
})));
|
|
194
|
-
} else if (
|
|
205
|
+
} else if (finalUser.location) {
|
|
195
206
|
// Convert single location string to array format
|
|
196
207
|
setLocations([{
|
|
197
208
|
id: 'existing-0',
|
|
198
|
-
name:
|
|
209
|
+
name: finalUser.location,
|
|
199
210
|
label: 'Location'
|
|
200
211
|
}]);
|
|
201
212
|
} else {
|
|
@@ -203,16 +214,16 @@ const AccountSettingsScreen = ({
|
|
|
203
214
|
}
|
|
204
215
|
|
|
205
216
|
// Handle links - simple and direct like other fields
|
|
206
|
-
if (
|
|
207
|
-
const urls =
|
|
217
|
+
if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
|
|
218
|
+
const urls = finalUser.linksMetadata.map(l => l.url);
|
|
208
219
|
setLinks(urls);
|
|
209
|
-
const metadataWithIds =
|
|
220
|
+
const metadataWithIds = finalUser.linksMetadata.map((link, index) => ({
|
|
210
221
|
...link,
|
|
211
222
|
id: link.id || `existing-${index}`
|
|
212
223
|
}));
|
|
213
224
|
setLinksMetadata(metadataWithIds);
|
|
214
|
-
} else if (Array.isArray(
|
|
215
|
-
const simpleLinks =
|
|
225
|
+
} else if (Array.isArray(finalUser.links)) {
|
|
226
|
+
const simpleLinks = finalUser.links.map(l => typeof l === 'string' ? l : l.link).filter(Boolean);
|
|
216
227
|
setLinks(simpleLinks);
|
|
217
228
|
const linksWithMetadata = simpleLinks.map((url, index) => ({
|
|
218
229
|
url,
|
|
@@ -222,12 +233,12 @@ const AccountSettingsScreen = ({
|
|
|
222
233
|
id: `existing-${index}`
|
|
223
234
|
}));
|
|
224
235
|
setLinksMetadata(linksWithMetadata);
|
|
225
|
-
} else if (
|
|
226
|
-
setLinks([
|
|
236
|
+
} else if (finalUser.website) {
|
|
237
|
+
setLinks([finalUser.website]);
|
|
227
238
|
setLinksMetadata([{
|
|
228
|
-
url:
|
|
229
|
-
title:
|
|
230
|
-
description: `Link to ${
|
|
239
|
+
url: finalUser.website,
|
|
240
|
+
title: finalUser.website.replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
|
241
|
+
description: `Link to ${finalUser.website}`,
|
|
231
242
|
image: undefined,
|
|
232
243
|
id: 'existing-0'
|
|
233
244
|
}]);
|
|
@@ -255,7 +266,7 @@ const AccountSettingsScreen = ({
|
|
|
255
266
|
previousUserIdRef.current = currentUserId;
|
|
256
267
|
previousAvatarRef.current = currentAvatar;
|
|
257
268
|
}
|
|
258
|
-
}, [
|
|
269
|
+
}, [finalUser, avatarFileId, isUpdatingAvatar, optimisticAvatarId]);
|
|
259
270
|
|
|
260
271
|
// Set initial editing field if provided via props (e.g., from navigation)
|
|
261
272
|
// Use a ref to track if we've already set the initial field to avoid loops
|
|
@@ -312,47 +323,46 @@ const AccountSettingsScreen = ({
|
|
|
312
323
|
}, []);
|
|
313
324
|
const saveField = (0, _react.useCallback)(async field => {
|
|
314
325
|
if (!field) return;
|
|
315
|
-
setIsSaving(true);
|
|
316
326
|
try {
|
|
317
327
|
switch (field) {
|
|
318
328
|
case 'displayName':
|
|
319
|
-
await
|
|
329
|
+
await updateProfileMutation.mutateAsync({
|
|
320
330
|
name: {
|
|
321
331
|
first: tempDisplayName,
|
|
322
332
|
last: tempLastName
|
|
323
333
|
}
|
|
324
|
-
}
|
|
334
|
+
});
|
|
325
335
|
setDisplayName(tempDisplayName);
|
|
326
336
|
setLastName(tempLastName);
|
|
327
337
|
break;
|
|
328
338
|
case 'username':
|
|
329
|
-
await
|
|
339
|
+
await updateProfileMutation.mutateAsync({
|
|
330
340
|
username: tempUsername
|
|
331
|
-
}
|
|
341
|
+
});
|
|
332
342
|
setUsername(tempUsername);
|
|
333
343
|
break;
|
|
334
344
|
case 'email':
|
|
335
|
-
await
|
|
345
|
+
await updateProfileMutation.mutateAsync({
|
|
336
346
|
email: tempEmail
|
|
337
|
-
}
|
|
347
|
+
});
|
|
338
348
|
setEmail(tempEmail);
|
|
339
349
|
break;
|
|
340
350
|
case 'bio':
|
|
341
|
-
await
|
|
351
|
+
await updateProfileMutation.mutateAsync({
|
|
342
352
|
bio: tempBio
|
|
343
|
-
}
|
|
353
|
+
});
|
|
344
354
|
setBio(tempBio);
|
|
345
355
|
break;
|
|
346
356
|
case 'location':
|
|
347
|
-
await
|
|
357
|
+
await updateProfileMutation.mutateAsync({
|
|
348
358
|
locations: tempLocations
|
|
349
|
-
}
|
|
359
|
+
});
|
|
350
360
|
setLocations(tempLocations);
|
|
351
361
|
break;
|
|
352
362
|
case 'links':
|
|
353
|
-
await
|
|
363
|
+
await updateProfileMutation.mutateAsync({
|
|
354
364
|
linksMetadata: tempLinksWithMetadata
|
|
355
|
-
}
|
|
365
|
+
});
|
|
356
366
|
setLinksMetadata(tempLinksWithMetadata);
|
|
357
367
|
setLinks(tempLinksWithMetadata.map(l => l.url));
|
|
358
368
|
break;
|
|
@@ -360,11 +370,9 @@ const AccountSettingsScreen = ({
|
|
|
360
370
|
setEditingField(null);
|
|
361
371
|
_sonner.toast.success(t('editProfile.toasts.saved') || 'Saved');
|
|
362
372
|
} catch (error) {
|
|
363
|
-
|
|
364
|
-
} finally {
|
|
365
|
-
setIsSaving(false);
|
|
373
|
+
// Error is already handled by mutation's onError
|
|
366
374
|
}
|
|
367
|
-
}, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata,
|
|
375
|
+
}, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata, updateProfileMutation, t]);
|
|
368
376
|
|
|
369
377
|
// Helper to get current value for a field
|
|
370
378
|
const getFieldCurrentValue = (0, _react.useCallback)(field => {
|
|
@@ -418,9 +426,8 @@ const AccountSettingsScreen = ({
|
|
|
418
426
|
}
|
|
419
427
|
}, [initialSection, sectionYPositions]);
|
|
420
428
|
const handleSave = async () => {
|
|
421
|
-
if (!
|
|
429
|
+
if (!finalUser) return;
|
|
422
430
|
try {
|
|
423
|
-
setIsSaving(true);
|
|
424
431
|
animateSaveButton(0.95); // Scale down slightly for animation
|
|
425
432
|
|
|
426
433
|
const updates = {
|
|
@@ -443,10 +450,10 @@ const AccountSettingsScreen = ({
|
|
|
443
450
|
}
|
|
444
451
|
|
|
445
452
|
// Handle avatar
|
|
446
|
-
if (avatarFileId !== (typeof
|
|
453
|
+
if (avatarFileId !== (typeof finalUser.avatar === 'string' ? finalUser.avatar : '')) {
|
|
447
454
|
updates.avatar = avatarFileId;
|
|
448
455
|
}
|
|
449
|
-
await
|
|
456
|
+
await updateProfileMutation.mutateAsync(updates);
|
|
450
457
|
_sonner.toast.success(t('editProfile.toasts.profileUpdated') || 'Profile updated successfully');
|
|
451
458
|
animateSaveButton(1); // Scale back to normal
|
|
452
459
|
|
|
@@ -456,10 +463,8 @@ const AccountSettingsScreen = ({
|
|
|
456
463
|
goBack();
|
|
457
464
|
}
|
|
458
465
|
} catch (error) {
|
|
459
|
-
|
|
466
|
+
// Error is already handled by mutation's onError
|
|
460
467
|
animateSaveButton(1); // Scale back to normal on error
|
|
461
|
-
} finally {
|
|
462
|
-
setIsSaving(false);
|
|
463
468
|
}
|
|
464
469
|
};
|
|
465
470
|
const handleAvatarRemove = () => {
|
|
@@ -676,7 +681,7 @@ const AccountSettingsScreen = ({
|
|
|
676
681
|
};
|
|
677
682
|
|
|
678
683
|
// Memoize display name for avatar
|
|
679
|
-
const displayNameForAvatar = (0, _react.useMemo)(() => (0, _userUtils.getDisplayName)(
|
|
684
|
+
const displayNameForAvatar = (0, _react.useMemo)(() => (0, _userUtils.getDisplayName)(finalUser), [finalUser]);
|
|
680
685
|
|
|
681
686
|
// Legacy renderEditingField function (fallback)
|
|
682
687
|
const renderEditingField = type => {
|
|
@@ -1174,7 +1179,7 @@ const AccountSettingsScreen = ({
|
|
|
1174
1179
|
})
|
|
1175
1180
|
});
|
|
1176
1181
|
};
|
|
1177
|
-
if (
|
|
1182
|
+
if (userLoading || !isAuthenticated) {
|
|
1178
1183
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
1179
1184
|
style: [styles.container, {
|
|
1180
1185
|
backgroundColor: themeStyles.backgroundColor,
|
|
@@ -1472,7 +1477,7 @@ const AccountSettingsScreen = ({
|
|
|
1472
1477
|
title: t('editProfile.items.previewProfile.title') || 'Preview Profile',
|
|
1473
1478
|
subtitle: t('editProfile.items.previewProfile.subtitle') || 'See how your profile looks to others',
|
|
1474
1479
|
onPress: () => navigate?.('Profile', {
|
|
1475
|
-
userId:
|
|
1480
|
+
userId: finalUser?.id
|
|
1476
1481
|
})
|
|
1477
1482
|
}, {
|
|
1478
1483
|
id: 'privacy-settings',
|