@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.
- package/lib/commonjs/crypto/keyManager.js +67 -22
- package/lib/commonjs/crypto/keyManager.js.map +1 -1
- package/lib/commonjs/index.js +66 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/components/BottomSheetRouter.js +100 -286
- package/lib/commonjs/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/commonjs/ui/components/GroupedItem.js +0 -3
- package/lib/commonjs/ui/components/GroupedItem.js.map +1 -1
- package/lib/commonjs/ui/components/OxyProvider.js +14 -19
- package/lib/commonjs/ui/components/OxyProvider.js.map +1 -1
- package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js +57 -0
- package/lib/commonjs/ui/components/fileManagement/AnimatedButton.js.map +1 -0
- package/lib/commonjs/ui/components/profile/EditBioModal.js +24 -156
- package/lib/commonjs/ui/components/profile/EditBioModal.js.map +1 -1
- package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js +28 -178
- package/lib/commonjs/ui/components/profile/EditDisplayNameModal.js.map +1 -1
- package/lib/commonjs/ui/components/profile/EditEmailModal.js +32 -159
- package/lib/commonjs/ui/components/profile/EditEmailModal.js.map +1 -1
- package/lib/commonjs/ui/components/profile/EditLocationModal.js +45 -227
- package/lib/commonjs/ui/components/profile/EditLocationModal.js.map +1 -1
- package/lib/commonjs/ui/components/profile/EditUsernameModal.js +30 -155
- package/lib/commonjs/ui/components/profile/EditUsernameModal.js.map +1 -1
- package/lib/commonjs/ui/hooks/mutations/mutationFactory.js +177 -0
- package/lib/commonjs/ui/hooks/mutations/mutationFactory.js.map +1 -0
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js +10 -123
- package/lib/commonjs/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js +2 -32
- package/lib/commonjs/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js +2 -31
- package/lib/commonjs/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/commonjs/ui/hooks/useFileFiltering.js +76 -0
- package/lib/commonjs/ui/hooks/useFileFiltering.js.map +1 -0
- package/lib/commonjs/ui/navigation/bottomSheetManager.js +43 -145
- package/lib/commonjs/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js +0 -2
- package/lib/commonjs/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +2 -2
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/utils/authHelpers.js +164 -0
- package/lib/commonjs/ui/utils/authHelpers.js.map +1 -0
- package/lib/commonjs/ui/utils/avatarUtils.js +18 -61
- package/lib/commonjs/ui/utils/avatarUtils.js.map +1 -1
- package/lib/module/crypto/keyManager.js +67 -22
- package/lib/module/crypto/keyManager.js.map +1 -1
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/components/BottomSheetRouter.js +102 -284
- package/lib/module/ui/components/BottomSheetRouter.js.map +1 -1
- package/lib/module/ui/components/GroupedItem.js +0 -3
- package/lib/module/ui/components/GroupedItem.js.map +1 -1
- package/lib/module/ui/components/OxyProvider.js +14 -19
- package/lib/module/ui/components/OxyProvider.js.map +1 -1
- package/lib/module/ui/components/fileManagement/AnimatedButton.js +50 -0
- package/lib/module/ui/components/fileManagement/AnimatedButton.js.map +1 -0
- package/lib/module/ui/components/profile/EditBioModal.js +24 -156
- package/lib/module/ui/components/profile/EditBioModal.js.map +1 -1
- package/lib/module/ui/components/profile/EditDisplayNameModal.js +28 -178
- package/lib/module/ui/components/profile/EditDisplayNameModal.js.map +1 -1
- package/lib/module/ui/components/profile/EditEmailModal.js +32 -159
- package/lib/module/ui/components/profile/EditEmailModal.js.map +1 -1
- package/lib/module/ui/components/profile/EditLocationModal.js +45 -227
- package/lib/module/ui/components/profile/EditLocationModal.js.map +1 -1
- package/lib/module/ui/components/profile/EditUsernameModal.js +30 -155
- package/lib/module/ui/components/profile/EditUsernameModal.js.map +1 -1
- package/lib/module/ui/hooks/mutations/mutationFactory.js +173 -0
- package/lib/module/ui/hooks/mutations/mutationFactory.js.map +1 -0
- package/lib/module/ui/hooks/mutations/useAccountMutations.js +10 -122
- package/lib/module/ui/hooks/mutations/useAccountMutations.js.map +1 -1
- package/lib/module/ui/hooks/queries/useAccountQueries.js +2 -32
- package/lib/module/ui/hooks/queries/useAccountQueries.js.map +1 -1
- package/lib/module/ui/hooks/queries/useServicesQueries.js +2 -31
- package/lib/module/ui/hooks/queries/useServicesQueries.js.map +1 -1
- package/lib/module/ui/hooks/useFileFiltering.js +72 -0
- package/lib/module/ui/hooks/useFileFiltering.js.map +1 -0
- package/lib/module/ui/navigation/bottomSheetManager.js +37 -135
- package/lib/module/ui/navigation/bottomSheetManager.js.map +1 -1
- package/lib/module/ui/screens/AccountSettingsScreen.js +0 -2
- package/lib/module/ui/screens/AccountSettingsScreen.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +2 -2
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/utils/authHelpers.js +154 -0
- package/lib/module/ui/utils/authHelpers.js.map +1 -0
- package/lib/module/ui/utils/avatarUtils.js +18 -61
- package/lib/module/ui/utils/avatarUtils.js.map +1 -1
- package/lib/typescript/commonjs/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +6 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts +2 -7
- package/lib/typescript/commonjs/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
- package/lib/typescript/commonjs/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/components/profile/EditBioModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/profile/EditEmailModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts +1 -0
- package/lib/typescript/commonjs/ui/components/profile/EditLocationModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts +76 -0
- package/lib/typescript/commonjs/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
- package/lib/typescript/commonjs/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts +1 -1
- package/lib/typescript/commonjs/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts +29 -0
- package/lib/typescript/commonjs/ui/hooks/useFileFiltering.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts +11 -60
- package/lib/typescript/commonjs/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts +99 -0
- package/lib/typescript/commonjs/ui/utils/authHelpers.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/utils/avatarUtils.d.ts.map +1 -1
- package/lib/typescript/module/crypto/keyManager.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +6 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts +2 -7
- package/lib/typescript/module/ui/components/BottomSheetRouter.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/GroupedItem.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/OxyProvider.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts +16 -0
- package/lib/typescript/module/ui/components/fileManagement/AnimatedButton.d.ts.map +1 -0
- package/lib/typescript/module/ui/components/profile/EditBioModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/profile/EditDisplayNameModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/profile/EditEmailModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts +1 -0
- package/lib/typescript/module/ui/components/profile/EditLocationModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/components/profile/EditUsernameModal.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts +76 -0
- package/lib/typescript/module/ui/hooks/mutations/mutationFactory.d.ts.map +1 -0
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts +29 -4
- package/lib/typescript/module/ui/hooks/mutations/useAccountMutations.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useAccountQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts +1 -1
- package/lib/typescript/module/ui/hooks/queries/useServicesQueries.d.ts.map +1 -1
- package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts +29 -0
- package/lib/typescript/module/ui/hooks/useFileFiltering.d.ts.map +1 -0
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts +11 -60
- package/lib/typescript/module/ui/navigation/bottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/module/ui/screens/AccountSettingsScreen.d.ts.map +1 -1
- package/lib/typescript/module/ui/utils/authHelpers.d.ts +99 -0
- package/lib/typescript/module/ui/utils/authHelpers.d.ts.map +1 -0
- package/lib/typescript/module/ui/utils/avatarUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/crypto/keyManager.ts +23 -22
- package/src/index.ts +25 -0
- package/src/ui/components/BottomSheetRouter.tsx +97 -319
- package/src/ui/components/GroupedItem.tsx +0 -4
- package/src/ui/components/OxyProvider.tsx +13 -18
- package/src/ui/components/fileManagement/AnimatedButton.tsx +56 -0
- package/src/ui/components/profile/EditBioModal.tsx +38 -176
- package/src/ui/components/profile/EditDisplayNameModal.tsx +48 -195
- package/src/ui/components/profile/EditEmailModal.tsx +49 -180
- package/src/ui/components/profile/EditLocationModal.tsx +76 -263
- package/src/ui/components/profile/EditUsernameModal.tsx +47 -175
- package/src/ui/hooks/mutations/mutationFactory.ts +215 -0
- package/src/ui/hooks/mutations/useAccountMutations.ts +48 -136
- package/src/ui/hooks/queries/useAccountQueries.ts +6 -33
- package/src/ui/hooks/queries/useServicesQueries.ts +6 -32
- package/src/ui/hooks/useFileFiltering.ts +115 -0
- package/src/ui/navigation/bottomSheetManager.ts +43 -150
- package/src/ui/screens/AccountSettingsScreen.tsx +0 -2
- package/src/ui/screens/FileManagementScreen.tsx +2 -2
- package/src/ui/utils/authHelpers.ts +183 -0
- package/src/ui/utils/avatarUtils.ts +25 -65
- package/lib/commonjs/ui/hooks/use-haptic-press.js +0 -21
- package/lib/commonjs/ui/hooks/use-haptic-press.js.map +0 -1
- package/lib/module/ui/hooks/use-haptic-press.js +0 -17
- package/lib/module/ui/hooks/use-haptic-press.js.map +0 -1
- package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts +0 -8
- package/lib/typescript/commonjs/ui/hooks/use-haptic-press.d.ts.map +0 -1
- package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts +0 -8
- package/lib/typescript/module/ui/hooks/use-haptic-press.d.ts.map +0 -1
- 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 =
|
|
8
|
-
var
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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","
|
|
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,MA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,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
|
-
|
|
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
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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
|
};
|