Page MenuHomePhabricator

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

Authored by atul on Jun 27 2023, 2:47 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 24, 2:48 PM
Unknown Object (File)
Tue, Jun 11, 3:46 PM
Unknown Object (File)
Tue, Jun 11, 1:00 PM
Unknown Object (File)
Fri, Jun 7, 11:10 AM
Unknown Object (File)
Thu, Jun 6, 7:41 AM
Unknown Object (File)
Tue, Jun 4, 4:53 PM
Unknown Object (File)
Tue, Jun 4, 5:51 AM
Unknown Object (File)
Sun, Jun 2, 10:32 PM
Subscribers

Details

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.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.Jun 27 2023, 2:50 PM
ashoat added inline comments.
lib/components/base-edit-user-avatar-provider.react.js
115–117 ↗(On Diff #28194)

async / await isn't needed if you're just forwarding a promise

This revision is now accepted and ready to land.Jun 28 2023, 6:00 PM
lib/components/base-edit-user-avatar-provider.react.js
115–117 ↗(On Diff #28194)

True, not sure what I was thinking leaving this IIFE

This revision was landed with ongoing or failed builds.Jul 28 2023, 12:52 PM
This revision was automatically updated to reflect the committed changes.