Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3520469
D8345.id28198.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8345.id28198.diff
View Options
diff --git a/lib/components/base-edit-user-avatar-provider.react.js b/lib/components/base-edit-user-avatar-provider.react.js
--- a/lib/components/base-edit-user-avatar-provider.react.js
+++ b/lib/components/base-edit-user-avatar-provider.react.js
@@ -78,14 +78,6 @@
const updateImageUserAvatar = React.useCallback(
async (selection: NativeMediaSelection) => {
- if (registrationModeRef.current.registrationMode === 'on') {
- registrationModeRef.current.successCallback({
- needsUpload: true,
- mediaSelection: selection,
- });
- return;
- }
-
const imageAvatarUpdateRequest = await uploadSelectedMedia(selection);
if (!imageAvatarUpdateRequest) {
return;
diff --git a/native/avatars/avatar-hooks.js b/native/avatars/avatar-hooks.js
--- a/native/avatars/avatar-hooks.js
+++ b/native/avatars/avatar-hooks.js
@@ -243,17 +243,39 @@
) => Promise<void> {
const editUserAvatarContext = React.useContext(EditUserAvatarContext);
invariant(editUserAvatarContext, 'editUserAvatarContext must be defined');
- const { updateImageUserAvatar } = editUserAvatarContext;
+ const {
+ updateImageUserAvatar,
+ getRegistrationModeEnabled,
+ getRegistrationModeSuccessCallback,
+ } = editUserAvatarContext;
const nativeUpdateUserImageAvatar = React.useCallback(
async (selection: NativeMediaSelection) => {
+ const registrationModeEnabled = getRegistrationModeEnabled();
+ if (registrationModeEnabled) {
+ const successCallback = getRegistrationModeSuccessCallback();
+ invariant(
+ successCallback,
+ 'successCallback must be defined if registrationModeEnabled is true',
+ );
+ successCallback({
+ needsUpload: true,
+ mediaSelection: selection,
+ });
+ return;
+ }
+
try {
await updateImageUserAvatar(selection);
} catch {
displayAvatarUpdateFailureAlert();
}
},
- [updateImageUserAvatar],
+ [
+ getRegistrationModeEnabled,
+ getRegistrationModeSuccessCallback,
+ updateImageUserAvatar,
+ ],
);
return nativeUpdateUserImageAvatar;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 12:27 AM (15 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697538
Default Alt Text
D8345.id28198.diff (2 KB)
Attached To
Mode
D8345: Move registrationMode-related logic from `updateImageUserAvatar` to `nativeUpdateUserImageAvatar`
Attached
Detach File
Event Timeline
Log In to Comment