HomePhabricator
Diffusion Comm 1dae32383fd5

[native] Introduce `useNativeSetUserAvatar` and use throughout `native`

Description

[native] Introduce useNativeSetUserAvatar and use throughout native

Summary:
Basically D8339 but for setUserAvatar instead of updateImageUserAvatar.

setUserAvatar in *EditUserAvatarProvider previously had a call to displayFailureAlert(...). However, this function is only relevant on native since we don't display alerts on web.

As part of making EditUserAvatarProvider platform-agnostic, we introduce the useNativeSetUserAvatar hook. It wraps the platform-agnostic setUserAvatar with a try/catch which displays an alert on native if an exception is caught in the catch block.

We replace usages of setUserAvatar on native with nativeSetUserAvatar (which is "created" via the hook).

This removes the final usage of displayFailureAlert in *EditUserAvatarProvider, so I'll remove the prop altogether in the next diff (to avoid cluttering up this one).


Depends on D8340

Test Plan: The modified flows continue to work as expected. When intentionally breaking the update_user_avatar endpoint, the alert continues to surface as expected.

Reviewers: ashoat, ginsu, rohan

Reviewed By: ashoat

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D8341

Details

Provenance
atulAuthored on Jul 28 2023, 12:43 PM
Reviewer
ashoat
Differential Revision
D8341: [native] Introduce `useNativeSetUserAvatar` and use throughout `native`
Parents
rCOMM13c5d23b5537: [native] Consume `useNativeUpdateUserImageAvatar` in…
Branches
Unknown
Tags
Unknown