Page MenuHomePhabricator

D8344.diff
No OneTemporary

D8344.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
@@ -33,7 +33,7 @@
export type EditUserAvatarContextType = {
+userAvatarSaveInProgress: boolean,
+updateImageUserAvatar: (selection: NativeMediaSelection) => Promise<void>,
- +setUserAvatar: (avatarRequest: UpdateUserAvatarRequest) => Promise<void>,
+ +baseSetUserAvatar: (avatarRequest: UpdateUserAvatarRequest) => Promise<void>,
+setRegistrationMode: (registrationMode: RegistrationMode) => void,
+getRegistrationModeEnabled: () => boolean,
+getRegistrationModeSuccessCallback: () => ?(UserAvatarSelection) => mixed,
@@ -101,7 +101,9 @@
[uploadSelectedMedia, dispatchActionPromise, updateUserAvatarCall],
);
- const setUserAvatar = React.useCallback(
+ // NOTE: Do NOT consume `baseSetUserAvatar` directly.
+ // Use platform-specific `[web/native]SetUserAvatar` instead.
+ const baseSetUserAvatar = React.useCallback(
async (request: UpdateUserAvatarRequest) => {
const promise = updateUserAvatarCall(request);
dispatchActionPromise(updateUserAvatarActionTypes, promise);
@@ -129,7 +131,7 @@
() => ({
userAvatarSaveInProgress,
updateImageUserAvatar,
- setUserAvatar,
+ baseSetUserAvatar,
setRegistrationMode,
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
@@ -137,7 +139,7 @@
[
userAvatarSaveInProgress,
updateImageUserAvatar,
- setUserAvatar,
+ baseSetUserAvatar,
setRegistrationMode,
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
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
@@ -201,7 +201,7 @@
const editUserAvatarContext = React.useContext(EditUserAvatarContext);
invariant(editUserAvatarContext, 'editUserAvatarContext must be defined');
const {
- setUserAvatar,
+ baseSetUserAvatar,
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
} = editUserAvatarContext;
@@ -223,7 +223,7 @@
}
try {
- await setUserAvatar(request);
+ await baseSetUserAvatar(request);
} catch {
displayAvatarUpdateFailureAlert();
}
@@ -231,7 +231,7 @@
[
getRegistrationModeEnabled,
getRegistrationModeSuccessCallback,
- setUserAvatar,
+ baseSetUserAvatar,
],
);
diff --git a/web/avatars/edit-user-avatar-menu.react.js b/web/avatars/edit-user-avatar-menu.react.js
--- a/web/avatars/edit-user-avatar-menu.react.js
+++ b/web/avatars/edit-user-avatar-menu.react.js
@@ -23,11 +23,11 @@
const editUserAvatarContext = React.useContext(EditUserAvatarContext);
invariant(editUserAvatarContext, 'editUserAvatarContext should be set');
- const { setUserAvatar } = editUserAvatarContext;
+ const { baseSetUserAvatar } = editUserAvatarContext;
const removeUserAvatar = React.useCallback(
- () => setUserAvatar({ type: 'remove' }),
- [setUserAvatar],
+ () => baseSetUserAvatar({ type: 'remove' }),
+ [baseSetUserAvatar],
);
const { pushModal } = useModalContext();
diff --git a/web/avatars/emoji-avatar-selection-modal.react.js b/web/avatars/emoji-avatar-selection-modal.react.js
--- a/web/avatars/emoji-avatar-selection-modal.react.js
+++ b/web/avatars/emoji-avatar-selection-modal.react.js
@@ -35,7 +35,7 @@
const editUserAvatarContext = React.useContext(EditUserAvatarContext);
invariant(editUserAvatarContext, 'editUserAvatarContext should be set');
- const { setUserAvatar, userAvatarSaveInProgress } = editUserAvatarContext;
+ const { baseSetUserAvatar, userAvatarSaveInProgress } = editUserAvatarContext;
const [updateAvatarStatus, setUpdateAvatarStatus] =
React.useState<?('success' | 'failure')>();
@@ -80,12 +80,12 @@
const onSaveAvatar = React.useCallback(async () => {
try {
- await setUserAvatar(pendingEmojiAvatar);
+ await baseSetUserAvatar(pendingEmojiAvatar);
setUpdateAvatarStatus('success');
} catch {
setUpdateAvatarStatus('failure');
}
- }, [pendingEmojiAvatar, setUserAvatar]);
+ }, [pendingEmojiAvatar, baseSetUserAvatar]);
let saveButtonContent;
let buttonColor;

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 6:36 PM (18 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2695828
Default Alt Text
D8344.diff (4 KB)

Event Timeline