Page MenuHomePhabricator

[native] improve factoring out redundant logic for saving an image user avatar
ClosedPublic

Authored by ginsu on Apr 26 2023, 3:25 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 30, 6:43 PM
Unknown Object (File)
Sun, Oct 27, 12:35 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Unknown Object (File)
Fri, Oct 25, 7:16 AM
Subscribers

Details

Summary

This diff has two small improvements for factoring out the redundant logic for saving an image avatar. The first improvement makes the callback in useUploadSelectedMedia return a ImageAvatarDBContent instead of a string. The second improvement factors out the update image avatar logic into its own function

Depends on D7622

Test Plan

flow and editing image user avatar still has expected behavior

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

ginsu requested review of this revision.Apr 26 2023, 3:43 AM
ginsu retitled this revision from [native] improve factoring out redundant logic for saving an image avatar to [native] improve factoring out redundant logic for saving an image user avatar.Apr 26 2023, 10:16 PM

It would be good to explain the reason for the changes here. Are these changes being made because you're going to reuse the factored-out code in a later diff in the stack, so it makes sense to factor out the shared logic here?

native/avatars/edit-user-avatar-provider.react.js
59

Why do we name this uploadUserAvatarSelectedMedia here instead of uploadSelectedMedia? We use the latter name in useSelectFromGalleryAndUpdateThreadAvatar, and it correspond better to the name of the hook.

This revision is now accepted and ready to land.Apr 27 2023, 4:30 AM

address comments/rebase before landing

It would be good to explain the reason for the changes here. Are these changes being made because you're going to reuse the factored-out code in a later diff in the stack, so it makes sense to factor out the shared logic here?

Yes sorry I should have done this when I initially put the diff up... this logic is directly shared and used by both the edit image avatar through gallery and camera. So I factored this logic out here in anticipation of the introduction of the edit user avatar camera modal which is introduced in the next diff