@oxyhq/services 5.21.5 → 5.21.7

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 (177) hide show
  1. package/lib/commonjs/crypto/keyManager.js +67 -22
  2. package/lib/commonjs/crypto/keyManager.js.map +1 -1
  3. package/lib/commonjs/index.js +66 -0
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/ui/components/BottomSheetRouter.js +100 -286
  6. package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
  7. package/lib/commonjs/ui/components/GroupedItem.js +0 -3
  8. package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
  9. package/lib/commonjs/ui/components/OxyProvider.js +14 -19
  10. package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
  11. package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js +57 -0
  12. package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js.map +1 -0
  13. package/lib/commonjs/ui/components/profile/EditBioModal.js +24 -156
  14. package/lib/commonjs/ui/components/profile/EditBioModal.js.map +1 -1
  15. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js +28 -178
  16. package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  17. package/lib/commonjs/ui/components/profile/EditEmailModal.js +32 -159
  18. package/lib/commonjs/ui/components/profile/EditEmailModal.js.map +1 -1
  19. package/lib/commonjs/ui/components/profile/EditLocationModal.js +45 -227
  20. package/lib/commonjs/ui/components/profile/EditLocationModal.js.map +1 -1
  21. package/lib/commonjs/ui/components/profile/EditUsernameModal.js +30 -155
  22. package/lib/commonjs/ui/components/profile/EditUsernameModal.js.map +1 -1
  23. package/lib/commonjs/ui/hooks/mutations/mutationFactory.js +177 -0
  24. package/lib/commonjs/ui/hooks/mutations/mutationFactory.js.map +1 -0
  25. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +10 -123
  26. package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  27. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -32
  28. package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
  29. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -31
  30. package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
  31. package/lib/commonjs/ui/hooks/useFileFiltering.js +76 -0
  32. package/lib/commonjs/ui/hooks/useFileFiltering.js.map +1 -0
  33. package/lib/commonjs/ui/navigation/bottomSheetManager.js +43 -145
  34. package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
  35. package/lib/commonjs/ui/screens/AccountSettingsScreen.js +0 -2
  36. package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
  37. package/lib/commonjs/ui/screens/FileManagementScreen.js +2 -2
  38. package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
  39. package/lib/commonjs/ui/utils/authHelpers.js +164 -0
  40. package/lib/commonjs/ui/utils/authHelpers.js.map +1 -0
  41. package/lib/commonjs/ui/utils/avatarUtils.js +18 -61
  42. package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
  43. package/lib/module/crypto/keyManager.js +67 -22
  44. package/lib/module/crypto/keyManager.js.map +1 -1
  45. package/lib/module/index.js +6 -0
  46. package/lib/module/index.js.map +1 -1
  47. package/lib/module/ui/components/BottomSheetRouter.js +102 -284
  48. package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
  49. package/lib/module/ui/components/GroupedItem.js +0 -3
  50. package/lib/module/ui/components/GroupedItem.js.map +1 -1
  51. package/lib/module/ui/components/OxyProvider.js +14 -19
  52. package/lib/module/ui/components/OxyProvider.js.map +1 -1
  53. package/lib/module/ui/components/fileManagement/AnimatedButton.js +50 -0
  54. package/lib/module/ui/components/fileManagement/AnimatedButton.js.map +1 -0
  55. package/lib/module/ui/components/profile/EditBioModal.js +24 -156
  56. package/lib/module/ui/components/profile/EditBioModal.js.map +1 -1
  57. package/lib/module/ui/components/profile/EditDisplayNameModal.js +28 -178
  58. package/lib/module/ui/components/profile/EditDisplayNameModal.js.map +1 -1
  59. package/lib/module/ui/components/profile/EditEmailModal.js +32 -159
  60. package/lib/module/ui/components/profile/EditEmailModal.js.map +1 -1
  61. package/lib/module/ui/components/profile/EditLocationModal.js +45 -227
  62. package/lib/module/ui/components/profile/EditLocationModal.js.map +1 -1
  63. package/lib/module/ui/components/profile/EditUsernameModal.js +30 -155
  64. package/lib/module/ui/components/profile/EditUsernameModal.js.map +1 -1
  65. package/lib/module/ui/hooks/mutations/mutationFactory.js +173 -0
  66. package/lib/module/ui/hooks/mutations/mutationFactory.js.map +1 -0
  67. package/lib/module/ui/hooks/mutations/useAccountMutations.js +10 -122
  68. package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
  69. package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -32
  70. package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
  71. package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -31
  72. package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
  73. package/lib/module/ui/hooks/useFileFiltering.js +72 -0
  74. package/lib/module/ui/hooks/useFileFiltering.js.map +1 -0
  75. package/lib/module/ui/navigation/bottomSheetManager.js +37 -135
  76. package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
  77. package/lib/module/ui/screens/AccountSettingsScreen.js +0 -2
  78. package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
  79. package/lib/module/ui/screens/FileManagementScreen.js +2 -2
  80. package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
  81. package/lib/module/ui/utils/authHelpers.js +154 -0
  82. package/lib/module/ui/utils/authHelpers.js.map +1 -0
  83. package/lib/module/ui/utils/avatarUtils.js +18 -61
  84. package/lib/module/ui/utils/avatarUtils.js.map +1 -1
  85. package/lib/typescript/commonjs/crypto/keyManager.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/index.d.ts +6 -0
  87. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts +2 -7
  89. package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/ui/components/GroupedItem.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
  93. package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/ui/components/profile/EditBioModal.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/ui/components/profile/EditEmailModal.d.ts.map +1 -1
  97. package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts +1 -0
  98. package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts +76 -0
  101. package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
  103. package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  105. package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +1 -1
  107. package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts +29 -0
  109. package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +11 -60
  111. package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  112. package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  113. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts +99 -0
  114. package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts.map +1 -0
  115. package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
  116. package/lib/typescript/module/crypto/keyManager.d.ts.map +1 -1
  117. package/lib/typescript/module/index.d.ts +6 -0
  118. package/lib/typescript/module/index.d.ts.map +1 -1
  119. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts +2 -7
  120. package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts.map +1 -1
  121. package/lib/typescript/module/ui/components/GroupedItem.d.ts.map +1 -1
  122. package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
  123. package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
  124. package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
  125. package/lib/typescript/module/ui/components/profile/EditBioModal.d.ts.map +1 -1
  126. package/lib/typescript/module/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
  127. package/lib/typescript/module/ui/components/profile/EditEmailModal.d.ts.map +1 -1
  128. package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts +1 -0
  129. package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts.map +1 -1
  130. package/lib/typescript/module/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
  131. package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts +76 -0
  132. package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
  133. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
  134. package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
  135. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +1 -1
  136. package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
  137. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +1 -1
  138. package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
  139. package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts +29 -0
  140. package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts.map +1 -0
  141. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +11 -60
  142. package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
  143. package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
  144. package/lib/typescript/module/ui/utils/authHelpers.d.ts +99 -0
  145. package/lib/typescript/module/ui/utils/authHelpers.d.ts.map +1 -0
  146. package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
  147. package/package.json +2 -2
  148. package/src/crypto/keyManager.ts +23 -22
  149. package/src/index.ts +25 -0
  150. package/src/ui/components/BottomSheetRouter.tsx +97 -319
  151. package/src/ui/components/GroupedItem.tsx +0 -4
  152. package/src/ui/components/OxyProvider.tsx +13 -18
  153. package/src/ui/components/fileManagement/AnimatedButton.tsx +56 -0
  154. package/src/ui/components/profile/EditBioModal.tsx +38 -176
  155. package/src/ui/components/profile/EditDisplayNameModal.tsx +48 -195
  156. package/src/ui/components/profile/EditEmailModal.tsx +49 -180
  157. package/src/ui/components/profile/EditLocationModal.tsx +76 -263
  158. package/src/ui/components/profile/EditUsernameModal.tsx +47 -175
  159. package/src/ui/hooks/mutations/mutationFactory.ts +215 -0
  160. package/src/ui/hooks/mutations/useAccountMutations.ts +48 -136
  161. package/src/ui/hooks/queries/useAccountQueries.ts +6 -33
  162. package/src/ui/hooks/queries/useServicesQueries.ts +6 -32
  163. package/src/ui/hooks/useFileFiltering.ts +115 -0
  164. package/src/ui/navigation/bottomSheetManager.ts +43 -150
  165. package/src/ui/screens/AccountSettingsScreen.tsx +0 -2
  166. package/src/ui/screens/FileManagementScreen.tsx +2 -2
  167. package/src/ui/utils/authHelpers.ts +183 -0
  168. package/src/ui/utils/avatarUtils.ts +25 -65
  169. package/lib/commonjs/ui/hooks/use-haptic-press.js +0 -21
  170. package/lib/commonjs/ui/hooks/use-haptic-press.js.map +0 -1
  171. package/lib/module/ui/hooks/use-haptic-press.js +0 -17
  172. package/lib/module/ui/hooks/use-haptic-press.js.map +0 -1
  173. package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts +0 -8
  174. package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts.map +0 -1
  175. package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts +0 -8
  176. package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts.map +0 -1
  177. package/src/ui/hooks/use-haptic-press.ts +0 -15
@@ -4,16 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EditUsernameModal = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _vectorIcons = require("@expo/vector-icons");
10
- var _useThemeStyles = require("../../hooks/useThemeStyles.js");
11
- var _useColorScheme = require("../../hooks/use-color-scheme.js");
12
- var _useI18n = require("../../hooks/useI18n.js");
13
- var _fonts = require("../../styles/fonts.js");
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _EditFieldModal = require("./EditFieldModal.js");
14
9
  var _useProfileEditing = require("../../hooks/useProfileEditing.js");
10
+ var _useI18n = require("../../hooks/useI18n.js");
15
11
  var _jsxRuntime = require("react/jsx-runtime");
16
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
13
  const EditUsernameModal = ({
18
14
  visible,
19
15
  onClose,
@@ -24,157 +20,36 @@ const EditUsernameModal = ({
24
20
  const {
25
21
  t
26
22
  } = (0, _useI18n.useI18n)();
27
- const colorScheme = (0, _useColorScheme.useColorScheme)();
28
- const themeStyles = (0, _useThemeStyles.useThemeStyles)(theme || 'light', colorScheme);
29
- const colors = themeStyles.colors;
30
23
  const {
31
- updateField,
32
- isSaving
24
+ updateField
33
25
  } = (0, _useProfileEditing.useProfileEditing)();
34
- const [username, setUsername] = (0, _react.useState)(initialValue);
35
- (0, _react.useEffect)(() => {
36
- if (visible) {
37
- setUsername(initialValue);
38
- }
39
- }, [visible, initialValue]);
40
- const handleSave = async () => {
41
- const success = await updateField('username', username);
42
- if (success) {
43
- onSave?.();
44
- onClose();
45
- }
46
- };
47
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditFieldModal.EditFieldModal, {
48
27
  visible: visible,
49
- animationType: "slide",
50
- transparent: true,
51
- onRequestClose: onClose,
52
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
53
- style: styles.modalOverlay,
54
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
55
- style: [styles.modalContent, {
56
- backgroundColor: colors.background
57
- }],
58
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
59
- style: styles.modalHeader,
60
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
61
- onPress: onClose,
62
- style: styles.closeButton,
63
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_vectorIcons.Ionicons, {
64
- name: "close",
65
- size: 24,
66
- color: colors.text
67
- })
68
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
69
- style: [styles.modalTitle, {
70
- color: colors.text
71
- }],
72
- children: t('editProfile.items.username.title') || 'Username'
73
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
74
- onPress: handleSave,
75
- disabled: isSaving || !username.trim(),
76
- style: [styles.saveButton, {
77
- opacity: isSaving || !username.trim() ? 0.5 : 1
78
- }],
79
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
80
- style: [styles.saveButtonText, {
81
- color: colors.tint
82
- }],
83
- children: isSaving ? 'Saving...' : 'Save'
84
- })
85
- })]
86
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
87
- style: styles.modalBody,
88
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
89
- style: styles.inputGroup,
90
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
91
- style: [styles.label, {
92
- color: colors.text
93
- }],
94
- children: t('editProfile.items.username.label') || 'Username'
95
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
96
- style: [styles.input, {
97
- backgroundColor: colors.card,
98
- color: colors.text,
99
- borderColor: colors.border
100
- }],
101
- value: username,
102
- onChangeText: setUsername,
103
- placeholder: t('editProfile.items.username.placeholder') || 'Choose a username',
104
- placeholderTextColor: colors.secondaryText,
105
- autoFocus: true,
106
- autoCapitalize: "none",
107
- autoCorrect: false,
108
- selectionColor: colors.tint
109
- })]
110
- })
111
- })]
112
- })
113
- })
28
+ onClose: onClose,
29
+ title: t('editProfile.items.username.title') || 'Username',
30
+ theme: theme,
31
+ onSave: onSave,
32
+ variant: "single",
33
+ fields: [{
34
+ key: 'username',
35
+ label: t('editProfile.items.username.label') || 'Username',
36
+ initialValue,
37
+ placeholder: t('editProfile.items.username.placeholder') || 'Choose a username',
38
+ validation: value => {
39
+ if (!value.trim()) {
40
+ return t('editProfile.items.username.required') || 'Username is required';
41
+ }
42
+ return undefined;
43
+ },
44
+ inputProps: {
45
+ autoCapitalize: 'none',
46
+ autoCorrect: false
47
+ }
48
+ }],
49
+ onSubmit: async data => {
50
+ return await updateField('username', data.username);
51
+ }
114
52
  });
115
53
  };
116
54
  exports.EditUsernameModal = EditUsernameModal;
117
- const styles = _reactNative.StyleSheet.create({
118
- modalOverlay: {
119
- flex: 1,
120
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
121
- justifyContent: 'flex-end'
122
- },
123
- modalContent: {
124
- borderTopLeftRadius: 20,
125
- borderTopRightRadius: 20,
126
- paddingTop: _reactNative.Platform.OS === 'ios' ? 20 : 16,
127
- maxHeight: '80%'
128
- },
129
- modalHeader: {
130
- flexDirection: 'row',
131
- alignItems: 'center',
132
- justifyContent: 'space-between',
133
- paddingHorizontal: 16,
134
- paddingBottom: 16,
135
- borderBottomWidth: _reactNative.StyleSheet.hairlineWidth,
136
- borderBottomColor: '#E5E5EA'
137
- },
138
- closeButton: {
139
- width: 40,
140
- height: 40,
141
- alignItems: 'center',
142
- justifyContent: 'center'
143
- },
144
- modalTitle: {
145
- fontSize: 18,
146
- fontWeight: '600',
147
- fontFamily: _fonts.fontFamilies.phuduSemiBold,
148
- flex: 1,
149
- textAlign: 'center'
150
- },
151
- saveButton: {
152
- paddingHorizontal: 16,
153
- paddingVertical: 8
154
- },
155
- saveButtonText: {
156
- fontSize: 16,
157
- fontWeight: '600',
158
- fontFamily: _fonts.fontFamilies.phuduSemiBold
159
- },
160
- modalBody: {
161
- padding: 16,
162
- gap: 16
163
- },
164
- inputGroup: {
165
- gap: 8
166
- },
167
- label: {
168
- fontSize: 14,
169
- fontWeight: '600',
170
- fontFamily: _fonts.fontFamilies.phuduSemiBold
171
- },
172
- input: {
173
- borderWidth: _reactNative.StyleSheet.hairlineWidth,
174
- borderRadius: 12,
175
- padding: 16,
176
- fontSize: 16,
177
- minHeight: 52
178
- }
179
- });
180
55
  //# sourceMappingURL=EditUsernameModal.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_vectorIcons","_useThemeStyles","_useColorScheme","_useI18n","_fonts","_useProfileEditing","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","EditUsernameModal","visible","onClose","initialValue","theme","onSave","useI18n","colorScheme","useColorScheme","themeStyles","useThemeStyles","colors","updateField","isSaving","useProfileEditing","username","setUsername","useState","useEffect","handleSave","success","jsx","Modal","animationType","transparent","onRequestClose","children","View","style","styles","modalOverlay","jsxs","modalContent","backgroundColor","background","modalHeader","TouchableOpacity","onPress","closeButton","Ionicons","name","size","color","text","Text","modalTitle","disabled","trim","saveButton","opacity","saveButtonText","tint","modalBody","inputGroup","label","TextInput","input","card","borderColor","border","value","onChangeText","placeholder","placeholderTextColor","secondaryText","autoFocus","autoCapitalize","autoCorrect","selectionColor","exports","StyleSheet","create","flex","justifyContent","borderTopLeftRadius","borderTopRightRadius","paddingTop","Platform","OS","maxHeight","flexDirection","alignItems","paddingHorizontal","paddingBottom","borderBottomWidth","hairlineWidth","borderBottomColor","width","height","fontSize","fontWeight","fontFamily","fontFamilies","phuduSemiBold","textAlign","paddingVertical","padding","gap","borderWidth","borderRadius","minHeight"],"sourceRoot":"../../../../../src","sources":["ui/components/profile/EditUsernameModal.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAAkE,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAD,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Q,EAAE,EAAE;IACZW,SAAS,EAAE;EACf;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_EditFieldModal","_useProfileEditing","_useI18n","_jsxRuntime","e","__esModule","default","EditUsernameModal","visible","onClose","initialValue","theme","onSave","t","useI18n","updateField","useProfileEditing","jsx","EditFieldModal","title","variant","fields","key","label","placeholder","validation","value","trim","undefined","inputProps","autoCapitalize","autoCorrect","onSubmit","data","username","exports"],"sourceRoot":"../../../../../src","sources":["ui/components/profile/EditUsernameModal.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAA8C,IAAAI,WAAA,GAAAJ,OAAA;AAAA,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAUvC,MAAMG,iBAAmD,GAAGA,CAAC;EAClEC,OAAO;EACPC,OAAO;EACPC,YAAY,GAAG,EAAE;EACjBC,KAAK,GAAG,OAAO;EACfC;AACF,CAAC,KAAK;EACJ,MAAM;IAAEC;EAAE,CAAC,GAAG,IAAAC,gBAAO,EAAC,CAAC;EACvB,MAAM;IAAEC;EAAY,CAAC,GAAG,IAAAC,oCAAiB,EAAC,CAAC;EAE3C,oBACE,IAAAb,WAAA,CAAAc,GAAA,EAACjB,eAAA,CAAAkB,cAAc;IACbV,OAAO,EAAEA,OAAQ;IACjBC,OAAO,EAAEA,OAAQ;IACjBU,KAAK,EAAEN,CAAC,CAAC,kCAAkC,CAAC,IAAI,UAAW;IAC3DF,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfQ,OAAO,EAAC,QAAQ;IAChBC,MAAM,EAAE,CACN;MACEC,GAAG,EAAE,UAAU;MACfC,KAAK,EAAEV,CAAC,CAAC,kCAAkC,CAAC,IAAI,UAAU;MAC1DH,YAAY;MACZc,WAAW,EAAEX,CAAC,CAAC,wCAAwC,CAAC,IAAI,mBAAmB;MAC/EY,UAAU,EAAGC,KAAK,IAAK;QACrB,IAAI,CAACA,KAAK,CAACC,IAAI,CAAC,CAAC,EAAE;UACjB,OAAOd,CAAC,CAAC,qCAAqC,CAAC,IAAI,sBAAsB;QAC3E;QACA,OAAOe,SAAS;MAClB,CAAC;MACDC,UAAU,EAAE;QACVC,cAAc,EAAE,MAAM;QACtBC,WAAW,EAAE;MACf;IACF,CAAC,CACD;IACFC,QAAQ,EAAE,MAAOC,IAAI,IAAK;MACxB,OAAO,MAAMlB,WAAW,CAAC,UAAU,EAAEkB,IAAI,CAACC,QAAkB,CAAC;IAC/D;EAAE,CACH,CAAC;AAEN,CAAC;AAACC,OAAA,CAAA5B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createGenericMutation = createGenericMutation;
7
+ exports.createProfileMutation = createProfileMutation;
8
+ var _queryKeys = require("../queries/queryKeys.js");
9
+ var _sonner = require("../../../lib/sonner.js");
10
+ var _authStore = require("../../stores/authStore.js");
11
+ /**
12
+ * Mutation Factory - Creates standardized mutations with optimistic updates
13
+ *
14
+ * This factory reduces boilerplate code for mutations that follow the common pattern:
15
+ * 1. Cancel outgoing queries
16
+ * 2. Snapshot previous data
17
+ * 3. Apply optimistic update
18
+ * 4. On error: rollback and show toast
19
+ * 5. On success: update cache, stores, and invalidate queries
20
+ */
21
+
22
+ /**
23
+ * Configuration for creating a standard profile mutation
24
+ */
25
+
26
+ /**
27
+ * Creates a standard profile mutation with optimistic updates
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const updateProfile = createProfileMutation({
32
+ * mutationFn: (updates) => oxyServices.updateProfile(updates),
33
+ * optimisticUpdate: (user, updates) => updates,
34
+ * errorMessage: 'Failed to update profile',
35
+ * });
36
+ * ```
37
+ */
38
+ function createProfileMutation(config, queryClient, activeSessionId) {
39
+ const {
40
+ mutationFn,
41
+ cancelQueryKeys = [],
42
+ optimisticUpdate,
43
+ errorMessage = 'Operation failed',
44
+ successMessage,
45
+ updateAuthStore = true,
46
+ invalidateUserQueries: shouldInvalidateUserQueries = true,
47
+ invalidateAccountQueries: shouldInvalidateAccountQueries = true,
48
+ onSuccess: customOnSuccess
49
+ } = config;
50
+ return {
51
+ mutationFn,
52
+ onMutate: async variables => {
53
+ // Cancel queries that might conflict
54
+ await queryClient.cancelQueries({
55
+ queryKey: _queryKeys.queryKeys.accounts.current()
56
+ });
57
+ for (const key of cancelQueryKeys) {
58
+ await queryClient.cancelQueries({
59
+ queryKey: key
60
+ });
61
+ }
62
+
63
+ // Snapshot previous user data
64
+ const previousUser = queryClient.getQueryData(_queryKeys.queryKeys.accounts.current());
65
+
66
+ // Apply optimistic update if provided
67
+ if (previousUser && optimisticUpdate) {
68
+ const updates = optimisticUpdate(previousUser, variables);
69
+ const optimisticUser = {
70
+ ...previousUser,
71
+ ...updates
72
+ };
73
+ queryClient.setQueryData(_queryKeys.queryKeys.accounts.current(), optimisticUser);
74
+ if (activeSessionId) {
75
+ queryClient.setQueryData(_queryKeys.queryKeys.users.profile(activeSessionId), optimisticUser);
76
+ }
77
+ }
78
+ return {
79
+ previousUser
80
+ };
81
+ },
82
+ onError: (error, _variables, context) => {
83
+ // Rollback optimistic update
84
+ if (context?.previousUser) {
85
+ queryClient.setQueryData(_queryKeys.queryKeys.accounts.current(), context.previousUser);
86
+ if (activeSessionId) {
87
+ queryClient.setQueryData(_queryKeys.queryKeys.users.profile(activeSessionId), context.previousUser);
88
+ }
89
+ }
90
+
91
+ // Show error toast
92
+ const message = typeof errorMessage === 'function' ? errorMessage(error) : error instanceof Error ? error.message : errorMessage;
93
+ _sonner.toast.error(message);
94
+ },
95
+ onSuccess: (data, variables) => {
96
+ // Update cache with server response
97
+ queryClient.setQueryData(_queryKeys.queryKeys.accounts.current(), data);
98
+ if (activeSessionId) {
99
+ queryClient.setQueryData(_queryKeys.queryKeys.users.profile(activeSessionId), data);
100
+ }
101
+
102
+ // Update authStore for immediate UI updates
103
+ if (updateAuthStore) {
104
+ _authStore.useAuthStore.getState().setUser(data);
105
+ }
106
+
107
+ // Invalidate related queries
108
+ if (shouldInvalidateUserQueries) {
109
+ (0, _queryKeys.invalidateUserQueries)(queryClient);
110
+ }
111
+ if (shouldInvalidateAccountQueries) {
112
+ (0, _queryKeys.invalidateAccountQueries)(queryClient);
113
+ }
114
+
115
+ // Show success toast if configured
116
+ if (successMessage) {
117
+ _sonner.toast.success(successMessage);
118
+ }
119
+
120
+ // Call custom onSuccess handler
121
+ if (customOnSuccess) {
122
+ customOnSuccess(data, variables, queryClient);
123
+ }
124
+ }
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Configuration for creating a generic mutation (non-profile)
130
+ */
131
+
132
+ /**
133
+ * Creates a generic mutation with optimistic updates
134
+ */
135
+ function createGenericMutation(config, queryClient) {
136
+ const {
137
+ mutationFn,
138
+ queryKey,
139
+ optimisticData,
140
+ errorMessage = 'Operation failed',
141
+ successMessage,
142
+ invalidateQueries = []
143
+ } = config;
144
+ return {
145
+ mutationFn,
146
+ onMutate: async variables => {
147
+ await queryClient.cancelQueries({
148
+ queryKey
149
+ });
150
+ const previous = queryClient.getQueryData(queryKey);
151
+ if (optimisticData) {
152
+ queryClient.setQueryData(queryKey, optimisticData(previous, variables));
153
+ }
154
+ return {
155
+ previous
156
+ };
157
+ },
158
+ onError: (error, _variables, context) => {
159
+ if (context?.previous !== undefined) {
160
+ queryClient.setQueryData(queryKey, context.previous);
161
+ }
162
+ _sonner.toast.error(error instanceof Error ? error.message : errorMessage);
163
+ },
164
+ onSuccess: data => {
165
+ queryClient.setQueryData(queryKey, data);
166
+ for (const key of invalidateQueries) {
167
+ queryClient.invalidateQueries({
168
+ queryKey: key
169
+ });
170
+ }
171
+ if (successMessage) {
172
+ _sonner.toast.success(successMessage);
173
+ }
174
+ }
175
+ };
176
+ }
177
+ //# sourceMappingURL=mutationFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_queryKeys","require","_sonner","_authStore","createProfileMutation","config","queryClient","activeSessionId","mutationFn","cancelQueryKeys","optimisticUpdate","errorMessage","successMessage","updateAuthStore","invalidateUserQueries","shouldInvalidateUserQueries","invalidateAccountQueries","shouldInvalidateAccountQueries","onSuccess","customOnSuccess","onMutate","variables","cancelQueries","queryKey","queryKeys","accounts","current","key","previousUser","getQueryData","updates","optimisticUser","setQueryData","users","profile","onError","error","_variables","context","message","Error","toast","data","useAuthStore","getState","setUser","success","createGenericMutation","optimisticData","invalidateQueries","previous","undefined"],"sourceRoot":"../../../../../src","sources":["ui/hooks/mutations/mutationFactory.ts"],"mappings":";;;;;;;AAaA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA,CACnCC,MAA+C,EAC/CC,WAAwB,EACxBC,eAA8B,EACwC;EACtE,MAAM;IACJC,UAAU;IACVC,eAAe,GAAG,EAAE;IACpBC,gBAAgB;IAChBC,YAAY,GAAG,kBAAkB;IACjCC,cAAc;IACdC,eAAe,GAAG,IAAI;IACtBC,qBAAqB,EAAEC,2BAA2B,GAAG,IAAI;IACzDC,wBAAwB,EAAEC,8BAA8B,GAAG,IAAI;IAC/DC,SAAS,EAAEC;EACb,CAAC,GAAGd,MAAM;EAEV,OAAO;IACLG,UAAU;IAEVY,QAAQ,EAAE,MAAOC,SAAS,IAAK;MAC7B;MACA,MAAMf,WAAW,CAACgB,aAAa,CAAC;QAAEC,QAAQ,EAAEC,oBA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CAAC;QAAEC;MAAS,CAAC,CAAC;MAC7C,MAAM2B,QAAQ,GAAG5C,WAAW,CAACuB,YAAY,CAAQN,QAAQ,CAAC;MAE1D,IAAIyB,cAAc,EAAE;QAClB1C,WAAW,CAAC0B,YAAY,CAAQT,QAAQ,EAAEyB,cAAc,CAACE,QAAQ,EAAE7B,SAAS,CAAC,CAAC;MAChF;MAEA,OAAO;QAAE6B;MAAS,CAAC;IACrB,CAAC;IAEDf,OAAO,EAAEA,CAACC,KAAK,EAAEC,UAAU,EAAEC,OAAO,KAAK;MACvC,IAAIA,OAAO,EAAEY,QAAQ,KAAKC,SAAS,EAAE;QACnC7C,WAAW,CAAC0B,YAAY,CAACT,QAAQ,EAAEe,OAAO,CAACY,QAAQ,CAAC;MACtD;MACAT,aAAK,CAACL,KAAK,CAACA,KAAK,YAAYI,KAAK,GAAGJ,KAAK,CAACG,OAAO,GAAG5B,YAAY,CAAC;IACpE,CAAC;IAEDO,SAAS,EAAGwB,IAAI,IAAK;MACnBpC,WAAW,CAAC0B,YAAY,CAACT,QAAQ,EAAEmB,IAAI,CAAC;MAExC,KAAK,MAAMf,GAAG,IAAIsB,iBAAiB,EAAE;QACnC3C,WAAW,CAAC2C,iBAAiB,CAAC;UAAE1B,QAAQ,EAAEI;QAAI,CAAC,CAAC;MAClD;MAEA,IAAIf,cAAc,EAAE;QAClB6B,aAAK,CAACK,OAAO,CAAClC,cAAc,CAAC;MAC/B;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -10,6 +10,7 @@ var _OxyContext = require("../../context/OxyContext.js");
10
10
  var _sonner = require("../../../lib/sonner.js");
11
11
  var _avatarUtils = require("../../utils/avatarUtils.js");
12
12
  var _authStore = require("../../stores/authStore.js");
13
+ var _authHelpers = require("../../utils/authHelpers.js");
13
14
  /**
14
15
  * Update user profile with optimistic updates and offline queue support
15
16
  */
@@ -22,37 +23,7 @@ const useUpdateProfile = () => {
22
23
  const queryClient = (0, _reactQuery.useQueryClient)();
23
24
  return (0, _reactQuery.useMutation)({
24
25
  mutationFn: async updates => {
25
- // Ensure we have a valid token before making the request
26
- if (!oxyServices.hasValidToken() && activeSessionId) {
27
- try {
28
- // Try to get token for the session
29
- await oxyServices.getTokenBySession(activeSessionId);
30
- } catch (tokenError) {
31
- // If getting token fails, might be an offline session - try syncing
32
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
33
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
34
- // Session sync should be handled by the app layer
35
- throw new Error('Session needs to be synced. Please try again.');
36
- } else {
37
- throw tokenError;
38
- }
39
- }
40
- }
41
- try {
42
- return await oxyServices.updateProfile(updates);
43
- } catch (error) {
44
- const errorMessage = error?.message || '';
45
- const status = error?.status || error?.response?.status;
46
-
47
- // Handle authentication errors
48
- if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
49
- // Session sync should be handled by the app layer
50
- throw new Error('Authentication failed. Please sign in again.');
51
- }
52
-
53
- // TanStack Query will automatically retry on network errors
54
- throw error;
55
- }
26
+ return (0, _authHelpers.authenticatedApiCall)(oxyServices, activeSessionId, () => oxyServices.updateProfile(updates));
56
27
  },
57
28
  // Optimistic update
58
29
  onMutate: async updates => {
@@ -128,21 +99,7 @@ const useUploadAvatar = () => {
128
99
  const queryClient = (0, _reactQuery.useQueryClient)();
129
100
  return (0, _reactQuery.useMutation)({
130
101
  mutationFn: async file => {
131
- // Ensure we have a valid token before making the request
132
- if (!oxyServices.hasValidToken() && activeSessionId) {
133
- try {
134
- await oxyServices.getTokenBySession(activeSessionId);
135
- } catch (tokenError) {
136
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
137
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
138
- // Session sync should be handled by the app layer
139
- throw new Error('Session needs to be synced. Please try again.');
140
- } else {
141
- throw tokenError;
142
- }
143
- }
144
- }
145
- try {
102
+ return (0, _authHelpers.authenticatedApiCall)(oxyServices, activeSessionId, async () => {
146
103
  // Upload file first
147
104
  const uploadResult = await oxyServices.assetUpload(file, 'public');
148
105
  const fileId = uploadResult?.file?.id || uploadResult?.id || uploadResult;
@@ -154,19 +111,7 @@ const useUploadAvatar = () => {
154
111
  return await oxyServices.updateProfile({
155
112
  avatar: fileId
156
113
  });
157
- } catch (error) {
158
- const errorMessage = error?.message || '';
159
- const status = error?.status || error?.response?.status;
160
-
161
- // Handle authentication errors
162
- if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
163
- // Session sync should be handled by the app layer
164
- throw new Error('Authentication failed. Please sign in again.');
165
- }
166
-
167
- // TanStack Query will automatically retry on network errors
168
- throw error;
169
- }
114
+ });
170
115
  },
171
116
  onMutate: async file => {
172
117
  await queryClient.cancelQueries({
@@ -296,38 +241,7 @@ const useUpdatePrivacySettings = () => {
296
241
  if (!targetUserId) {
297
242
  throw new Error('User ID is required');
298
243
  }
299
-
300
- // Ensure we have a valid token before making the request
301
- if (!oxyServices.hasValidToken() && activeSessionId) {
302
- try {
303
- // Try to get token for the session
304
- await oxyServices.getTokenBySession(activeSessionId);
305
- } catch (tokenError) {
306
- // If getting token fails, might be an offline session - try syncing
307
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
308
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
309
- // Session sync should be handled by the app layer
310
- throw new Error('Session needs to be synced. Please try again.');
311
- } else {
312
- throw tokenError;
313
- }
314
- }
315
- }
316
- try {
317
- return await oxyServices.updatePrivacySettings(settings, targetUserId);
318
- } catch (error) {
319
- const errorMessage = error?.message || '';
320
- const status = error?.status || error?.response?.status;
321
-
322
- // Handle authentication errors
323
- if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
324
- // Session sync should be handled by the app layer
325
- throw new Error('Authentication failed. Please sign in again.');
326
- }
327
-
328
- // TanStack Query will automatically retry on network errors
329
- throw error;
330
- }
244
+ return (0, _authHelpers.authenticatedApiCall)(oxyServices, activeSessionId, () => oxyServices.updatePrivacySettings(settings, targetUserId));
331
245
  },
332
246
  // Optimistic update
333
247
  onMutate: async ({
@@ -424,10 +338,13 @@ const useUpdatePrivacySettings = () => {
424
338
  });
425
339
  };
426
340
 
341
+ /** Uploaded file data structure from API */
342
+
343
+ /** Upload result type that supports both single file and batch responses */
344
+ exports.useUpdatePrivacySettings = useUpdatePrivacySettings;
427
345
  /**
428
346
  * Upload file with authentication handling and progress tracking
429
347
  */
430
- exports.useUpdatePrivacySettings = useUpdatePrivacySettings;
431
348
  const useUploadFile = () => {
432
349
  const {
433
350
  oxyServices,
@@ -440,37 +357,7 @@ const useUploadFile = () => {
440
357
  metadata,
441
358
  onProgress
442
359
  }) => {
443
- // Ensure we have a valid token before making the request
444
- if (!oxyServices.hasValidToken() && activeSessionId) {
445
- try {
446
- // Try to get token for the session
447
- await oxyServices.getTokenBySession(activeSessionId);
448
- } catch (tokenError) {
449
- // If getting token fails, might be an offline session - try syncing
450
- const errorMessage = tokenError instanceof Error ? tokenError.message : String(tokenError);
451
- if (errorMessage.includes('AUTH_REQUIRED_OFFLINE_SESSION') || errorMessage.includes('offline')) {
452
- // Session sync should be handled by the app layer
453
- throw new Error('Session needs to be synced. Please try again.');
454
- } else {
455
- throw tokenError;
456
- }
457
- }
458
- }
459
- try {
460
- return await oxyServices.assetUpload(file, visibility, metadata, onProgress);
461
- } catch (error) {
462
- const errorMessage = error?.message || '';
463
- const status = error?.status || error?.response?.status;
464
-
465
- // Handle authentication errors
466
- if (status === 401 || errorMessage.includes('Authentication required') || errorMessage.includes('Invalid or missing authorization header')) {
467
- // Session sync should be handled by the app layer
468
- throw new Error('Authentication failed. Please sign in again.');
469
- }
470
-
471
- // TanStack Query will automatically retry on network errors
472
- throw error;
473
- }
360
+ return (0, _authHelpers.authenticatedApiCall)(oxyServices, activeSessionId, () => oxyServices.assetUpload(file, visibility, metadata, onProgress));
474
361
  }
475
362
  });
476
363
  };