Page MenuHomePhabricator

D8345.id29208.diff
No OneTemporary

D8345.id29208.diff

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

Mime Type
text/plain
Expires
Tue, Dec 24, 12:52 AM (15 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2697538
Default Alt Text
D8345.id29208.diff (2 KB)

Event Timeline