Page MenuHomePhabricator

[native] Add function to open native picker
ClosedPublic

Authored by bartek on Feb 1 2023, 8:54 AM.
Tags
None
Referenced Files
F3245793: D6495.id21981.diff
Thu, Nov 14, 8:20 PM
Unknown Object (File)
Wed, Oct 30, 5:59 AM
Unknown Object (File)
Wed, Oct 30, 5:59 AM
Unknown Object (File)
Wed, Oct 30, 5:59 AM
Unknown Object (File)
Wed, Oct 30, 5:58 AM
Unknown Object (File)
Wed, Oct 30, 5:53 AM
Unknown Object (File)
Oct 2 2024, 9:55 PM
Unknown Object (File)
Sep 30 2024, 3:21 AM
Subscribers

Details

Summary

Created a function that opens the native image picker interface using the expo-image-picker library and then processes the result to be compatible with our MediaLibrarySelection type. Finally, it updates the component state to make the selection prepended to the MediaGalleryKeyboard and queued to send.

Useful docs: image picker options, returned data.

Depends on D6493, D6494

Test Plan

Created a test button that triggers this function and ensured (both platforms) that:

  • native picker opens
  • multiple results can be picked
  • selected media are prepended to the gallery and enqueued to send

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.Feb 1 2023, 10:15 AM

Demo looks great! nits and question inline

native/media/media-gallery-keyboard.react.js
302

Tiny nit but we usually do ID instead of Id

304

Thought it was a requirement of the filesystem (or the ones I'm familiar with) that every file must have a name? My assumption might be incorrect or not apply to all platforms?

336

Tiny nit but we'd usually style this as selectionURIs

native/media/media-gallery-keyboard.react.js
304

Replied here: https://phab.comm.dev/D6493#194506

We're doing our best effort here, and finally falling back to an empty string which is then handled by the media processing code.

native/media/media-gallery-keyboard.react.js
304

Thanks for writing that up, looks like just two variable naming nits and this should be good to land

ashoat requested changes to this revision.Feb 1 2023, 11:01 AM

Passing back to you with question. If this is handled in a separate / later diff with a patch or something, feel free to let me know and I can accept

native/media/media-gallery-keyboard.react.js
316

I think it was possible for this value to be falsey on Android? MediaLibrarySelection expects it to be set, so we could be introducing some issues here. Context here

This revision now requires changes to proceed.Feb 1 2023, 11:01 AM
native/media/media-gallery-keyboard.react.js
316

That's right, it's optional and I should fix the types here.

However, it is handled correctly, because when you git grep mediaNativeID, you can see that it is null-checked everywhere.

I quickly set it to optional in the type MediaLibrarySelection definition and flow still doesn't complain.

native/media/media-gallery-keyboard.react.js
316

Awesome!! Okay, so the only thing to do here it is to fix the types

  • Made mediaNativeID type optional
  • Applied suggestions regarding naming conventions
ashoat requested changes to this revision.Feb 2 2023, 11:47 AM

Question to you, feel free to re-request review if this will be handled in a different place

native/media/media-gallery-keyboard.react.js
344 ↗(On Diff #21830)

The plan is now to call inputState.sendMultimediaMessage from here directly, right? Is that mean to be handled in this diff or in a later one?

This revision now requires changes to proceed.Feb 2 2023, 11:47 AM
bartek requested review of this revision.Feb 3 2023, 3:57 AM
bartek added inline comments.
native/media/media-gallery-keyboard.react.js
344 ↗(On Diff #21830)

I prefer doing it in a separate diff to keep the history consistent

This revision is now accepted and ready to land.Feb 3 2023, 10:58 AM