HomePhabricator
Diffusion Comm 3ece4b60c42e

[native] Introduce naive `useSelectFromGalleryAndUpdateUserAvatar` hook

Description

[native] Introduce naive useSelectFromGalleryAndUpdateUserAvatar hook

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)

Reviewers: ashoat, ginsu

Reviewed By: ashoat

Subscribers: tomek, ginsu

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

Details

Provenance
atulAuthored on Apr 18 2023, 6:33 PM
Reviewer
ashoat
Differential Revision
D7510: [native] Introduce naive `useSelectFromGalleryAndUpdateUserAvatar` hook
Parents
rCOMMa51ab899c288: [native] Move `ThreadAvatar` "inside" `EditThreadAvatar`
Branches
Unknown
Tags
Unknown