Page MenuHomePhabricator

Move registrationMode-related logic from `setUserAvatar` to `nativeSetUserAvatar`
ClosedPublic

Authored by atul on Jun 27 2023, 5:19 PM.
Tags
None
Referenced Files
F2144784: D8343.id29201.diff
Sat, Jun 29, 8:58 PM
F2143570: D8343.id29203.diff
Sat, Jun 29, 5:24 PM
Unknown Object (File)
Wed, Jun 26, 2:55 PM
Unknown Object (File)
Mon, Jun 24, 2:48 PM
Unknown Object (File)
Thu, Jun 20, 11:45 PM
Unknown Object (File)
Fri, Jun 14, 7:10 AM
Unknown Object (File)
Fri, Jun 14, 5:37 AM
Unknown Object (File)
Thu, Jun 13, 7:50 AM
Subscribers

Details

Summary

The registrationMode-related code is native-specific and was pretty interwoven with the logic in setUserAvatar/updateImageUserAvatar.

This diff begins to untangle the two and move registrationMode-related logic to native/.../avatar-hooks.js.

As of this diff, setUserAvatar(request: UpdateUserAvatarRequest) is fully platform-agnostic and can be used on both native (via nativeSetUserAvatar) and web (via upcoming webSetUserAvatar).


Depends on D8342

Test Plan

As of D8341, all native codepaths go through nativeSetUserAvatar instead of setUserAvatar.

Continue to be able to set non-image avatars + remove avatars on both native and web as expected.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.Jun 27 2023, 5:34 PM
This revision is now accepted and ready to land.Jun 28 2023, 10:09 AM
ashoat requested changes to this revision.Jun 28 2023, 6:20 PM

I'm confused – what was not platform-agnostic about this before? It seems like you still need the state in lib, so I'm not really sure what this diff is achieving

This revision now requires changes to proceed.Jun 28 2023, 6:20 PM
atul requested review of this revision.EditedJun 28 2023, 6:42 PM

I'm confused – what was not platform-agnostic about this before? It seems like you still need the state in lib, so I'm not really sure what this diff is achieving

updateImageUserAvatar previously took (selection: NativeMediaSelection) as an argument to satisfy the mediaSelection: NativeMediaSelection field of the object passed to registrationModeRef.current.successCallback when needsUpload is true.

As of D8346 the argument is changed to (imageAvatarUpdateRequest: ImageAvatarDBContent) so updateUserImageAvatar can be used by both web and native. It becomes the responsibility of platform-specific avatar-hooks to provide platform-agnostic ImageAvatarDBContent to *EditUserAvatarProvider.

Because I was moving the registrationMode stuff out of updateImageUserAvatar, I decided to do the same for setUserAvatar for consistency/symmetry. I thought it'd be best if the registrationMode stuff for image and non-image avatars were handled in the same file in nativeUpdateUserImageAvatar(...) and nativeSetUserAvatar(...) instead of in nativeUpdateUserImageAvatar(...) in avatar-hooks and setUserAvatar(...) in *EditUserAvatarProvider.

registrationMode is only relevant on native because there's no registration flow on web (and based on my understanding there won't be in the foreseeable future). We are leaving setRegistrationMode, getRegistrationModeEnabled, etc here because it doesn't affect anything on web and I wanted to limit the amount of refactor work.

This revision is now accepted and ready to land.Jun 28 2023, 6:46 PM

resolve merge conflicts before landing

This revision was landed with ongoing or failed builds.Jul 28 2023, 1:19 PM
This revision was automatically updated to reflect the committed changes.