Page MenuHomePhabricator

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

Authored by atul on Aug 5 2023, 2:50 AM.
Tags
None
Referenced Files
F3390160: D8736.diff
Fri, Nov 29, 10:30 PM
Unknown Object (File)
Sat, Nov 9, 8:19 PM
Unknown Object (File)
Sat, Nov 9, 3:39 AM
Unknown Object (File)
Fri, Nov 1, 4:10 AM
Unknown Object (File)
Oct 23 2024, 10:57 AM
Unknown Object (File)
Oct 19 2024, 9:08 AM
Unknown Object (File)
Oct 19 2024, 9:08 AM
Unknown Object (File)
Oct 19 2024, 9:08 AM
Subscribers

Details

Summary

This diff involved moving selectFromGalleryAndUpdateThreadAvatar from EditThreadAvatarProvider to avatar-hooks.react.js.

  1. 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 providers and hooks made things difficult to work w/ when dealing w/ 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 the <input> to launch file selection, and then handle selected media from onChange callback... so things aren't as "sequential."
NOTE: This is the "thread avatar version" of D8318.
Test Plan

Still able to select and set image thread avatars on native.

Diff Detail

Repository
rCOMM Comm
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage