@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
@@ -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
- const updateUser = (0, _authStore.useAuthStore)(state => state.updateUser);
64
- // Get user directly from store to ensure reactivity to avatar changes
65
- const user = (0, _authStore.useAuthStore)(state => state.user) || userFromContext;
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 [isSaving, setIsSaving] = (0, _react.useState)(false);
68
- const [isUpdatingAvatar, setIsUpdatingAvatar] = (0, _react.useState)(false);
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 (user) {
168
- const currentUserId = user.id;
169
- const currentAvatar = typeof user.avatar === 'string' ? user.avatar : '';
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 user.name === 'string' ? user.name : user.name?.first || user.name?.full || '';
178
- const userLastName = typeof user.name === 'object' ? user.name?.last || '' : '';
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(user.username || '');
182
- setEmail(user.email || '');
183
- setBio(user.bio || '');
184
- setLocation(user.location || '');
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 (user.locations && Array.isArray(user.locations)) {
188
- setLocations(user.locations.map((loc, index) => ({
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 (user.location) {
205
+ } else if (finalUser.location) {
195
206
  // Convert single location string to array format
196
207
  setLocations([{
197
208
  id: 'existing-0',
198
- name: user.location,
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 (user.linksMetadata && Array.isArray(user.linksMetadata)) {
207
- const urls = user.linksMetadata.map(l => l.url);
217
+ if (finalUser.linksMetadata && Array.isArray(finalUser.linksMetadata)) {
218
+ const urls = finalUser.linksMetadata.map(l => l.url);
208
219
  setLinks(urls);
209
- const metadataWithIds = user.linksMetadata.map((link, index) => ({
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(user.links)) {
215
- const simpleLinks = user.links.map(l => typeof l === 'string' ? l : l.link).filter(Boolean);
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 (user.website) {
226
- setLinks([user.website]);
236
+ } else if (finalUser.website) {
237
+ setLinks([finalUser.website]);
227
238
  setLinksMetadata([{
228
- url: user.website,
229
- title: user.website.replace(/^https?:\/\//, '').replace(/\/$/, ''),
230
- description: `Link to ${user.website}`,
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
- }, [user, avatarFileId, isUpdatingAvatar, optimisticAvatarId]);
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 updateUser({
329
+ await updateProfileMutation.mutateAsync({
320
330
  name: {
321
331
  first: tempDisplayName,
322
332
  last: tempLastName
323
333
  }
324
- }, oxyServices);
334
+ });
325
335
  setDisplayName(tempDisplayName);
326
336
  setLastName(tempLastName);
327
337
  break;
328
338
  case 'username':
329
- await updateUser({
339
+ await updateProfileMutation.mutateAsync({
330
340
  username: tempUsername
331
- }, oxyServices);
341
+ });
332
342
  setUsername(tempUsername);
333
343
  break;
334
344
  case 'email':
335
- await updateUser({
345
+ await updateProfileMutation.mutateAsync({
336
346
  email: tempEmail
337
- }, oxyServices);
347
+ });
338
348
  setEmail(tempEmail);
339
349
  break;
340
350
  case 'bio':
341
- await updateUser({
351
+ await updateProfileMutation.mutateAsync({
342
352
  bio: tempBio
343
- }, oxyServices);
353
+ });
344
354
  setBio(tempBio);
345
355
  break;
346
356
  case 'location':
347
- await updateUser({
357
+ await updateProfileMutation.mutateAsync({
348
358
  locations: tempLocations
349
- }, oxyServices);
359
+ });
350
360
  setLocations(tempLocations);
351
361
  break;
352
362
  case 'links':
353
- await updateUser({
363
+ await updateProfileMutation.mutateAsync({
354
364
  linksMetadata: tempLinksWithMetadata
355
- }, oxyServices);
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
- _sonner.toast.error(error?.message || t('editProfile.toasts.saveFailed') || 'Failed to save');
364
- } finally {
365
- setIsSaving(false);
373
+ // Error is already handled by mutation's onError
366
374
  }
367
- }, [tempDisplayName, tempLastName, tempUsername, tempEmail, tempBio, tempLocations, tempLinksWithMetadata, updateUser, oxyServices, t]);
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 (!user) return;
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 user.avatar === 'string' ? user.avatar : '')) {
453
+ if (avatarFileId !== (typeof finalUser.avatar === 'string' ? finalUser.avatar : '')) {
447
454
  updates.avatar = avatarFileId;
448
455
  }
449
- await updateUser(updates, oxyServices);
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
- _sonner.toast.error(error.message || t('editProfile.toasts.updateFailed') || 'Failed to update profile');
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)(user), [user]);
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 (isLoading || !isAuthenticated) {
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: user?.id
1480
+ userId: finalUser?.id
1476
1481
  })
1477
1482
  }, {
1478
1483
  id: 'privacy-settings',