@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.
Files changed (190) hide show
  1. package/lib/commonjs/core/mixins/OxyServices.assets.js +15 -0
  2. package/lib/commonjs/core/mixins/OxyServices.assets.js.map +1 -1
  3. package/lib/commonjs/core/mixins/OxyServices.user.js +14 -13
  4. package/lib/commonjs/core/mixins/OxyServices.user.js.map +1 -1
  5. package/lib/commonjs/crypto/keyManager.js +164 -3
  6. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  7. package/lib/commonjs/crypto/signatureService.js +26 -0
  8. package/lib/commonjs/crypto/signatureService.js.map +1 -1
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/ui/components/GroupedSection.js +1 -1
  11. package/lib/commonjs/ui/components/GroupedSection.js.map +1 -1
  12. package/lib/commonjs/ui/components/OxyProvider.js +71 -24
  13. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  14. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js +1 -4
  15. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  16. package/lib/commonjs/ui/context/OxyContext.js +177 -4
  17. package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
  18. package/lib/commonjs/ui/context/hooks/useAuthOperations.js +148 -49
  19. package/lib/commonjs/ui/context/hooks/useAuthOperations.js.map +1 -1
  20. package/lib/commonjs/ui/context/hooks/useSessionManagement.js +22 -2
  21. package/lib/commonjs/ui/context/hooks/useSessionManagement.js.map +1 -1
  22. package/lib/commonjs/ui/hooks/mutations/index.js +28 -0
  23. package/lib/commonjs/ui/hooks/mutations/index.js.map +1 -0
  24. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +314 -0
  25. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -0
  26. package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js +193 -0
  27. package/lib/commonjs/ui/hooks/mutations/useServicesMutations.js.map +1 -0
  28. package/lib/commonjs/ui/hooks/queries/index.js +39 -0
  29. package/lib/commonjs/ui/hooks/queries/index.js.map +1 -0
  30. package/lib/commonjs/ui/hooks/queries/queryKeys.js +85 -0
  31. package/lib/commonjs/ui/hooks/queries/queryKeys.js.map +1 -0
  32. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +145 -0
  33. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -0
  34. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +138 -0
  35. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -0
  36. package/lib/commonjs/ui/hooks/queryClient.js +117 -0
  37. package/lib/commonjs/ui/hooks/queryClient.js.map +1 -0
  38. package/lib/commonjs/ui/hooks/useIdentityMutations.js +111 -0
  39. package/lib/commonjs/ui/hooks/useIdentityMutations.js.map +1 -0
  40. package/lib/commonjs/ui/hooks/useProfileEditing.js +42 -58
  41. package/lib/commonjs/ui/hooks/useProfileEditing.js.map +1 -1
  42. package/lib/commonjs/ui/hooks/useQueryClient.js +20 -0
  43. package/lib/commonjs/ui/hooks/useQueryClient.js.map +1 -0
  44. package/lib/commonjs/ui/hooks/useSessionManagement.js +22 -2
  45. package/lib/commonjs/ui/hooks/useSessionManagement.js.map +1 -1
  46. package/lib/commonjs/ui/screens/AccountOverviewScreen.js +43 -42
  47. package/lib/commonjs/ui/screens/AccountOverviewScreen.js.map +1 -1
  48. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +63 -58
  49. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  50. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js +6 -6
  51. package/lib/commonjs/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  52. package/lib/commonjs/ui/stores/accountStore.js +57 -42
  53. package/lib/commonjs/ui/stores/accountStore.js.map +1 -1
  54. package/lib/commonjs/ui/stores/authStore.js +4 -25
  55. package/lib/commonjs/ui/stores/authStore.js.map +1 -1
  56. package/lib/module/core/mixins/OxyServices.assets.js +15 -0
  57. package/lib/module/core/mixins/OxyServices.assets.js.map +1 -1
  58. package/lib/module/core/mixins/OxyServices.user.js +14 -13
  59. package/lib/module/core/mixins/OxyServices.user.js.map +1 -1
  60. package/lib/module/crypto/keyManager.js +164 -3
  61. package/lib/module/crypto/keyManager.js.map +1 -1
  62. package/lib/module/crypto/signatureService.js +26 -0
  63. package/lib/module/crypto/signatureService.js.map +1 -1
  64. package/lib/module/index.js.map +1 -1
  65. package/lib/module/ui/components/GroupedSection.js +1 -1
  66. package/lib/module/ui/components/GroupedSection.js.map +1 -1
  67. package/lib/module/ui/components/OxyProvider.js +72 -25
  68. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  69. package/lib/module/ui/components/profile/EditDisplayNameModal.js +1 -4
  70. package/lib/module/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  71. package/lib/module/ui/context/OxyContext.js +176 -4
  72. package/lib/module/ui/context/OxyContext.js.map +1 -1
  73. package/lib/module/ui/context/hooks/useAuthOperations.js +148 -49
  74. package/lib/module/ui/context/hooks/useAuthOperations.js.map +1 -1
  75. package/lib/module/ui/context/hooks/useSessionManagement.js +22 -2
  76. package/lib/module/ui/context/hooks/useSessionManagement.js.map +1 -1
  77. package/lib/module/ui/hooks/mutations/index.js +6 -0
  78. package/lib/module/ui/hooks/mutations/index.js.map +1 -0
  79. package/lib/module/ui/hooks/mutations/useAccountMutations.js +308 -0
  80. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -0
  81. package/lib/module/ui/hooks/mutations/useServicesMutations.js +185 -0
  82. package/lib/module/ui/hooks/mutations/useServicesMutations.js.map +1 -0
  83. package/lib/module/ui/hooks/queries/index.js +7 -0
  84. package/lib/module/ui/hooks/queries/index.js.map +1 -0
  85. package/lib/module/ui/hooks/queries/queryKeys.js +78 -0
  86. package/lib/module/ui/hooks/queries/queryKeys.js.map +1 -0
  87. package/lib/module/ui/hooks/queries/useAccountQueries.js +136 -0
  88. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -0
  89. package/lib/module/ui/hooks/queries/useServicesQueries.js +130 -0
  90. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -0
  91. package/lib/module/ui/hooks/queryClient.js +110 -0
  92. package/lib/module/ui/hooks/queryClient.js.map +1 -0
  93. package/lib/module/ui/hooks/useIdentityMutations.js +105 -0
  94. package/lib/module/ui/hooks/useIdentityMutations.js.map +1 -0
  95. package/lib/module/ui/hooks/useProfileEditing.js +43 -59
  96. package/lib/module/ui/hooks/useProfileEditing.js.map +1 -1
  97. package/lib/module/ui/hooks/useQueryClient.js +15 -0
  98. package/lib/module/ui/hooks/useQueryClient.js.map +1 -0
  99. package/lib/module/ui/hooks/useSessionManagement.js +22 -2
  100. package/lib/module/ui/hooks/useSessionManagement.js.map +1 -1
  101. package/lib/module/ui/screens/AccountOverviewScreen.js +43 -42
  102. package/lib/module/ui/screens/AccountOverviewScreen.js.map +1 -1
  103. package/lib/module/ui/screens/AccountSettingsScreen.js +63 -58
  104. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  105. package/lib/module/ui/screens/WelcomeNewUserScreen.js +6 -6
  106. package/lib/module/ui/screens/WelcomeNewUserScreen.js.map +1 -1
  107. package/lib/module/ui/stores/accountStore.js +57 -42
  108. package/lib/module/ui/stores/accountStore.js.map +1 -1
  109. package/lib/module/ui/stores/authStore.js +4 -25
  110. package/lib/module/ui/stores/authStore.js.map +1 -1
  111. package/lib/typescript/core/mixins/OxyServices.assets.d.ts +7 -1
  112. package/lib/typescript/core/mixins/OxyServices.assets.d.ts.map +1 -1
  113. package/lib/typescript/core/mixins/OxyServices.user.d.ts +4 -5
  114. package/lib/typescript/core/mixins/OxyServices.user.d.ts.map +1 -1
  115. package/lib/typescript/core/mixins/index.d.ts +1 -1
  116. package/lib/typescript/core/mixins/index.d.ts.map +1 -1
  117. package/lib/typescript/crypto/keyManager.d.ts +19 -2
  118. package/lib/typescript/crypto/keyManager.d.ts.map +1 -1
  119. package/lib/typescript/crypto/signatureService.d.ts +5 -0
  120. package/lib/typescript/crypto/signatureService.d.ts.map +1 -1
  121. package/lib/typescript/index.d.ts +1 -1
  122. package/lib/typescript/index.d.ts.map +1 -1
  123. package/lib/typescript/models/interfaces.d.ts +21 -0
  124. package/lib/typescript/models/interfaces.d.ts.map +1 -1
  125. package/lib/typescript/ui/components/OxyProvider.d.ts.map +1 -1
  126. package/lib/typescript/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
  127. package/lib/typescript/ui/context/OxyContext.d.ts +4 -0
  128. package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
  129. package/lib/typescript/ui/context/hooks/useAuthOperations.d.ts.map +1 -1
  130. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts +3 -1
  131. package/lib/typescript/ui/context/hooks/useSessionManagement.d.ts.map +1 -1
  132. package/lib/typescript/ui/hooks/mutations/index.d.ts +3 -0
  133. package/lib/typescript/ui/hooks/mutations/index.d.ts.map +1 -0
  134. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts +25 -0
  135. package/lib/typescript/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -0
  136. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts +23 -0
  137. package/lib/typescript/ui/hooks/mutations/useServicesMutations.d.ts.map +1 -0
  138. package/lib/typescript/ui/hooks/queries/index.d.ts +4 -0
  139. package/lib/typescript/ui/hooks/queries/index.d.ts.map +1 -0
  140. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts +56 -0
  141. package/lib/typescript/ui/hooks/queries/queryKeys.d.ts.map +1 -0
  142. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts +41 -0
  143. package/lib/typescript/ui/hooks/queries/useAccountQueries.d.ts.map +1 -0
  144. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts +34 -0
  145. package/lib/typescript/ui/hooks/queries/useServicesQueries.d.ts.map +1 -0
  146. package/lib/typescript/ui/hooks/queryClient.d.ts +19 -0
  147. package/lib/typescript/ui/hooks/queryClient.d.ts.map +1 -0
  148. package/lib/typescript/ui/hooks/useIdentityMutations.d.ts +29 -0
  149. package/lib/typescript/ui/hooks/useIdentityMutations.d.ts.map +1 -0
  150. package/lib/typescript/ui/hooks/useProfileEditing.d.ts.map +1 -1
  151. package/lib/typescript/ui/hooks/useQueryClient.d.ts +7 -0
  152. package/lib/typescript/ui/hooks/useQueryClient.d.ts.map +1 -0
  153. package/lib/typescript/ui/hooks/useSessionManagement.d.ts +3 -1
  154. package/lib/typescript/ui/hooks/useSessionManagement.d.ts.map +1 -1
  155. package/lib/typescript/ui/screens/AccountOverviewScreen.d.ts.map +1 -1
  156. package/lib/typescript/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  157. package/lib/typescript/ui/screens/WelcomeNewUserScreen.d.ts.map +1 -1
  158. package/lib/typescript/ui/stores/accountStore.d.ts.map +1 -1
  159. package/lib/typescript/ui/stores/authStore.d.ts +0 -4
  160. package/lib/typescript/ui/stores/authStore.d.ts.map +1 -1
  161. package/package.json +6 -5
  162. package/src/core/mixins/OxyServices.assets.ts +16 -1
  163. package/src/core/mixins/OxyServices.user.ts +17 -10
  164. package/src/crypto/keyManager.ts +177 -2
  165. package/src/crypto/signatureService.ts +30 -0
  166. package/src/index.ts +4 -1
  167. package/src/models/interfaces.ts +23 -0
  168. package/src/ui/components/GroupedSection.tsx +1 -1
  169. package/src/ui/components/OxyProvider.tsx +91 -37
  170. package/src/ui/components/profile/EditDisplayNameModal.tsx +1 -3
  171. package/src/ui/context/OxyContext.tsx +185 -2
  172. package/src/ui/context/hooks/useAuthOperations.ts +171 -58
  173. package/src/ui/context/hooks/useSessionManagement.ts +24 -1
  174. package/src/ui/hooks/mutations/index.ts +4 -0
  175. package/src/ui/hooks/mutations/useAccountMutations.ts +277 -0
  176. package/src/ui/hooks/mutations/useServicesMutations.ts +164 -0
  177. package/src/ui/hooks/queries/index.ts +5 -0
  178. package/src/ui/hooks/queries/queryKeys.ts +73 -0
  179. package/src/ui/hooks/queries/useAccountQueries.ts +126 -0
  180. package/src/ui/hooks/queries/useServicesQueries.ts +121 -0
  181. package/src/ui/hooks/queryClient.ts +112 -0
  182. package/src/ui/hooks/useIdentityMutations.ts +115 -0
  183. package/src/ui/hooks/useProfileEditing.ts +46 -60
  184. package/src/ui/hooks/useQueryClient.ts +17 -0
  185. package/src/ui/hooks/useSessionManagement.ts +24 -1
  186. package/src/ui/screens/AccountOverviewScreen.tsx +38 -46
  187. package/src/ui/screens/AccountSettingsScreen.tsx +54 -54
  188. package/src/ui/screens/WelcomeNewUserScreen.tsx +13 -12
  189. package/src/ui/stores/accountStore.ts +54 -43
  190. 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
- const updateUser = useAuthStore(state => state.updateUser);
59
- // Get user directly from store to ensure reactivity to avatar changes
60
- const user = useAuthStore(state => state.user) || userFromContext;
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 [isSaving, setIsSaving] = useState(false);
63
- const [isUpdatingAvatar, setIsUpdatingAvatar] = useState(false);
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 (user) {
163
- const currentUserId = user.id;
164
- const currentAvatar = typeof user.avatar === 'string' ? user.avatar : '';
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 user.name === 'string' ? user.name : user.name?.first || user.name?.full || '';
173
- const userLastName = typeof user.name === 'object' ? user.name?.last || '' : '';
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(user.username || '');
177
- setEmail(user.email || '');
178
- setBio(user.bio || '');
179
- setLocation(user.location || '');
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 (user.locations && Array.isArray(user.locations)) {
183
- setLocations(user.locations.map((loc, index) => ({
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 (user.location) {
200
+ } else if (finalUser.location) {
190
201
  // Convert single location string to array format
191
202
  setLocations([{
192
203
  id: 'existing-0',
193
- name: user.location,
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 (user.linksMetadata && Array.isArray(user.linksMetadata)) {
202
- const urls = user.linksMetadata.map(l => l.url);
212
+ if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
213
+ const urls = finalUser.linksMetadata.map(l => l.url);
203
214
  setLinks(urls);
204
- const metadataWithIds = user.linksMetadata.map((link, index) => ({
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(user.links)) {
210
- const simpleLinks = user.links.map(l => typeof l === 'string' ? l : l.link).filter(Boolean);
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 (user.website) {
221
- setLinks([user.website]);
231
+ } else if (finalUser.website) {
232
+ setLinks([finalUser.website]);
222
233
  setLinksMetadata([{
223
- url: user.website,
224
- title: user.website.replace(/^https?:\/\//, '').replace(/\/$/, ''),
225
- description: `Link to ${user.website}`,
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
- }, [user, avatarFileId, isUpdatingAvatar, optimisticAvatarId]);
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 updateUser({
324
+ await updateProfileMutation.mutateAsync({
315
325
  name: {
316
326
  first: tempDisplayName,
317
327
  last: tempLastName
318
328
  }
319
- }, oxyServices);
329
+ });
320
330
  setDisplayName(tempDisplayName);
321
331
  setLastName(tempLastName);
322
332
  break;
323
333
  case 'username':
324
- await updateUser({
334
+ await updateProfileMutation.mutateAsync({
325
335
  username: tempUsername
326
- }, oxyServices);
336
+ });
327
337
  setUsername(tempUsername);
328
338
  break;
329
339
  case 'email':
330
- await updateUser({
340
+ await updateProfileMutation.mutateAsync({
331
341
  email: tempEmail
332
- }, oxyServices);
342
+ });
333
343
  setEmail(tempEmail);
334
344
  break;
335
345
  case 'bio':
336
- await updateUser({
346
+ await updateProfileMutation.mutateAsync({
337
347
  bio: tempBio
338
- }, oxyServices);
348
+ });
339
349
  setBio(tempBio);
340
350
  break;
341
351
  case 'location':
342
- await updateUser({
352
+ await updateProfileMutation.mutateAsync({
343
353
  locations: tempLocations
344
- }, oxyServices);
354
+ });
345
355
  setLocations(tempLocations);
346
356
  break;
347
357
  case 'links':
348
- await updateUser({
358
+ await updateProfileMutation.mutateAsync({
349
359
  linksMetadata: tempLinksWithMetadata
350
- }, oxyServices);
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
- toast.error(error?.message || t('editProfile.toasts.saveFailed') || 'Failed to save');
359
- } finally {
360
- setIsSaving(false);
368
+ // Error is already handled by mutation's onError
361
369
  }
362
- }, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata, updateUser, oxyServices, t]);
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 (!user) return;
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 user.avatar === 'string' ? user.avatar : '')) {
448
+ if (avatarFileId !== (typeof finalUser.avatar === 'string' ? finalUser.avatar : '')) {
442
449
  updates.avatar = avatarFileId;
443
450
  }
444
- await updateUser(updates, oxyServices);
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
- toast.error(error.message || t('editProfile.toasts.updateFailed') || 'Failed to update profile');
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(user), [user]);
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 (isLoading || !isAuthenticated) {
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: user?.id
1475
+ userId: finalUser?.id
1471
1476
  })
1472
1477
  }, {
1473
1478
  id: 'privacy-settings',