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)
Mon, Nov 25, 8:41 PM
Unknown Object (File)
Mon, Nov 25, 8:41 PM
Unknown Object (File)
Sun, Nov 24, 5:44 AM
Unknown Object (File)
Sun, Nov 24, 5:44 AM
Unknown Object (File)
Sun, Nov 24, 5:43 AM
Unknown Object (File)
Sun, Nov 24, 5:43 AM
Unknown Object (File)
Sun, Nov 24, 5:43 AM
Unknown Object (File)
Sun, Nov 24, 5:43 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
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #25798)

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