-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[native] Introduce
useNativeUpdateUserImageAvatar()
to `avatar-hook…
…s.react` Summary: The `updateImageUserAvatar` function within `*EditUserAvatarProvider` previously contained a call to the `displayFailureAlert(...)` function, which was passed in via props. However, the `displayFailureAlert` function is only relevant on `native` as we surface errors differently on `web`. As part of making `EditUserAvatarProvider` platform-agnostic, we introduce the `useNativeUpdateUserImageAvatar()` hook. The function it "creates" encapsulates its call to `updateImageUserAvatar` in a `try/catch` block that handles errors in a `native`-specific way. As a result, `updateImageUserAvatar` can throw a plain old exception that will be caught by platform-specific "wrapper" functions. In subsequent diffs we'll do the same thing for `setUserAvatar` so we can completely remove the `displayFailureAlert` prop from `*EditUserAvatarProvider`. After that we'll work on removing the `useUploadSelectedMedia` prop so the provider is fully "platform-agnostic." At that point we'll be able to consolidate `BaseEditUserAvatarProvider`, `NativeEditUserAvatarProvider`, and `WebEditUserAvatarProvider` into a single `EditUserAvatarProvider` component. Test Plan: 1. Modify `update_user_avatar` endpoint to throw `ServerError` (we can't just kill `keyserver` because we want to make sure the alert is triggered by the `update_user_avatar`-specific codepath which we modified). 2. Try to set a user image avatar via "Camera" flow 3. Ensure that I see expected Alert. Also, make sure the "happy case" (unmodified `update_user_avatar` endpoint) continues working as expected). WARNING: ~~I haven't actually gone through the Test Plan yet, will sequence at the end of all of the refactors and **definitely** before landing.~~ {F609721} {F609722} Reviewers: ashoat, ginsu, rohan Reviewed By: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D8339
- Loading branch information
1 parent
4ca1082
commit 3e3e93c
Showing
5 changed files
with
44 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters