Page MenuHomePhabricator

[native] Introduce naive `useSelectFromGalleryAndUpdateUserAvatar` hook
ClosedPublic

Authored by atul on Apr 18 2023, 6:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 6:33 AM
Unknown Object (File)
Fri, Nov 15, 1:54 AM
Unknown Object (File)
Wed, Nov 6, 3:30 AM
Unknown Object (File)
Wed, Nov 6, 3:30 AM
Unknown Object (File)
Mon, Nov 4, 11:21 PM
Unknown Object (File)
Mon, Nov 4, 11:21 PM
Unknown Object (File)
Nov 1 2024, 1:03 AM
Unknown Object (File)
Nov 1 2024, 1:03 AM
Subscribers

Details

Summary

This hook composes together the previously created image avatar-related hooks (eg useProcessSelectedMedia, useUploadProcessedMedia, etc) to

  1. Display system image picker to user so they can pick image
  2. Processes the selected image
  3. Uploads the processed image
  4. Updates the user avatar with the uploadID of the uploaded processed image

There's still work to be done in terms of displaying status/progress, handling errors (eg cleaning up temporary files), etc... but this diff gets things working "end to end." Putting it up now to unblock @ginsu's camera work.

NOTE: Reusing this hook in EditThreadAvatar for now as a placeholder to satisfy Flow/ESLint/etc. Will introduce equivalent for threads in next diff.
NOTE: Renamed useSelectAndUploadFromGallery to useSelectFromGallery after "pulling out" useProcessSelectedMedia and useUploadProcessedMedia calls. Those are now handled in the higher level useSelectFromGalleryAndUpdateUserAvatar hook (and upcoming thread avatar equivalent).

Depends on D7509

Test Plan

Able to successfully set image avatar:

Simulator Screenshot - Fresh iPhone 14 Pro - 2023-04-18 at 21.42.33.png (2×1 px, 386 KB)

Simulator Screenshot - Fresh iPhone 14 Pro - 2023-04-18 at 21.42.28.png (2×1 px, 231 KB)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul added inline comments.
native/avatars/avatar-hooks.js
144–159 ↗(On Diff #25318)

Yes this error handling leaves plenty to be desired.. I'm actively working on it.

atul published this revision for review.Apr 18 2023, 6:44 PM
ashoat added inline comments.
native/avatars/avatar-hooks.js
116 ↗(On Diff #25318)

Can we explicitly return undefined here?

275 ↗(On Diff #25318)

Does this actually get used outside of this file?

This revision is now accepted and ready to land.Apr 19 2023, 6:09 AM
atul marked an inline comment as done.Apr 19 2023, 9:16 AM
atul added inline comments.
native/avatars/avatar-hooks.js
116 ↗(On Diff #25318)

Will update

275 ↗(On Diff #25318)

No, will remove

atul marked an inline comment as done.

address feedback

This revision was landed with ongoing or failed builds.Apr 19 2023, 9:28 AM
This revision was automatically updated to reflect the committed changes.