From cf12040be85f5e1902537da618729f1ffaf16dbe Mon Sep 17 00:00:00 2001 From: Atul Madhugiri Date: Fri, 4 Aug 2023 14:35:57 -0700 Subject: [PATCH] [web] Call `baseSetUserAvatar` from `onImageSelected` Summary: Once image is successfully uploaded, we make call to `baseSetUserAvatar` from `EditUserAvatarContext`. As of this diff, users can set emoji, image, ENS avatars (and remove them). What's missing is `ImageAvatarSelectionModal` to handle cropping + some error handling. Those will be handled after the thread avatar work. --- Depends on D8725 Test Plan: Works as expected: {F674875} Reviewers: ashoat, ginsu Reviewed By: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D8726 --- web/avatars/edit-user-avatar-menu.react.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web/avatars/edit-user-avatar-menu.react.js b/web/avatars/edit-user-avatar-menu.react.js index ad9275bf44..dc854b4b8e 100644 --- a/web/avatars/edit-user-avatar-menu.react.js +++ b/web/avatars/edit-user-avatar-menu.react.js @@ -69,8 +69,11 @@ function EditUserAvatarMenu(): React.Node { const uploadAvatarMedia = useUploadAvatarMedia(); const onImageSelected = React.useCallback( - event => uploadAvatarMedia(event.target.files[0]), - [uploadAvatarMedia], + async event => { + const uploadResult = await uploadAvatarMedia(event.target.files[0]); + baseSetUserAvatar({ type: 'image', uploadID: uploadResult.id }); + }, + [baseSetUserAvatar, uploadAvatarMedia], ); const imageMenuItem = React.useMemo(