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)
Thu, Oct 3, 12:08 AM
Unknown Object (File)
Fri, Sep 20, 10:11 PM
Unknown Object (File)
Fri, Sep 20, 1:57 PM
Unknown Object (File)
Fri, Sep 13, 4:12 AM
Unknown Object (File)
Sun, Sep 8, 9:24 AM
Unknown Object (File)
Sun, Sep 8, 9:24 AM
Unknown Object (File)
Sun, Sep 8, 9:24 AM
Unknown Object (File)
Sun, Sep 8, 9:23 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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul added inline comments.
native/avatars/avatar-hooks.js
144–159

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

Can we explicitly return undefined here?

275

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

Will update

275

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.