Page MenuHomePhabricator

[lib] Move `selectFromGalleryAndUpdateUserAvatar` from provider to `avatar-hooks`
ClosedPublic

Authored by atul on Jun 26 2023, 3:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 23, 2:22 PM
Unknown Object (File)
Sat, Nov 9, 8:18 PM
Unknown Object (File)
Sat, Nov 9, 6:22 PM
Unknown Object (File)
Sat, Nov 9, 8:55 AM
Unknown Object (File)
Sat, Nov 9, 3:39 AM
Unknown Object (File)
Fri, Nov 8, 9:56 PM
Unknown Object (File)
Thu, Nov 7, 4:34 AM
Unknown Object (File)
Fri, Nov 1, 4:10 AM
Subscribers

Details

Summary

This diff involved moving selectFromGalleryAndUpdateUserAvatar from Edit*AvatarProvider to avatar-hooks.react.js... which makes a lot more sense.

  1. As discussed D8316, this allows us to better decouple the avatar providers and hooks. The providers are an entity(user/thread)-specific, but platform-agnostic interface b/w client and keyserver, whereas avatar hooks are platform-specific implementations. The coupling between the providers and hooks made things difficult to work w/ when dealing with implementing image avatars on web.
  2. Previously we had hooks which were "functions" of provider state which itself was a "function" of hooks. This diff starts to enforce the idea that hooks are "downstream" of providers which makes things easier to reason about.
  3. selectFromGallery functionality is specific to native where we launch the image gallery programmatically and process the media selection. On web, we "virtually" click on an <input> to launch file selection, and then handle selected media from onChange callback... so things aren't as "sequential."
  4. We're one step closer to merging WebEditUserAvatarProvider and NativeEditUserAvatarProvider.

Depends on D8316

Test Plan

Still able to select and set image avatar from native.

Diff Detail

Repository
rCOMM Comm
Branch
arcpatch-D8318 (branched from master)
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

atul published this revision for review.Jun 26 2023, 3:32 PM

really like this idea of having hooks be platform-specific and providers being platform-agnostic

This revision is now accepted and ready to land.Jun 26 2023, 10:31 PM
This revision was landed with ongoing or failed builds.Jun 27 2023, 9:17 AM
This revision was automatically updated to reflect the committed changes.