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)
Tue, Dec 17, 9:03 AM
Unknown Object (File)
Sat, Nov 23, 4:19 PM
Unknown Object (File)
Sat, Nov 23, 1:19 PM
Unknown Object (File)
Sat, Nov 23, 1:19 PM
Unknown Object (File)
Nov 21 2024, 5:49 PM
Unknown Object (File)
Nov 19 2024, 2:58 AM
Unknown Object (File)
Nov 18 2024, 1:15 PM
Unknown Object (File)
Nov 5 2024, 11:09 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.