diff --git a/native/keyboard/keyboard-input-host.react.js b/native/keyboard/keyboard-input-host.react.js --- a/native/keyboard/keyboard-input-host.react.js +++ b/native/keyboard/keyboard-input-host.react.js @@ -6,6 +6,7 @@ import { KeyboardAccessoryView } from 'react-native-keyboard-input'; import type { MediaLibrarySelection } from 'lib/types/media-types'; +import type { ThreadInfo } from 'lib/types/thread-types'; import { type InputState, InputStateContext } from '../input/input-state'; import { mediaGalleryKeyboardName } from '../media/media-gallery-keyboard.react'; @@ -16,6 +17,7 @@ type BaseProps = { +textInputRef?: ?React.ElementRef, + +threadInfo?: any, }; type Props = { ...BaseProps, @@ -46,11 +48,15 @@ const kbComponent = KeyboardInputHost.mediaGalleryOpen(this.props) ? mediaGalleryKeyboardName : null; + const kbInitialProps = { + ...this.props.styles.kbInitialProps, + threadInfo: this.props.keyboardState.getMediaGalleryThread(), + }; return ( , + result: { + selections: $ReadOnlyArray, + threadInfo: ?ThreadInfo, + }, ) => { const { keyboardState } = this.props; + const mediaGalleryThread = + keyboardState.getMediaGalleryThread() ?? result.threadInfo; keyboardState.dismissKeyboard(); - const mediaGalleryThread = keyboardState.getMediaGalleryThread(); if (!mediaGalleryThread) { return; } @@ -74,7 +84,7 @@ inputState, 'inputState should be set in onMediaGalleryItemSelected', ); - inputState.sendMultimediaMessage(selections, mediaGalleryThread); + inputState.sendMultimediaMessage(result.selections, mediaGalleryThread); }; hideMediaGallery = () => { diff --git a/native/media/media-gallery-keyboard.react.js b/native/media/media-gallery-keyboard.react.js --- a/native/media/media-gallery-keyboard.react.js +++ b/native/media/media-gallery-keyboard.react.js @@ -22,6 +22,7 @@ } from 'lib/media/file-utils'; import { useIsAppForegrounded } from 'lib/shared/lifecycle-utils'; import type { MediaLibrarySelection } from 'lib/types/media-types'; +import type { ThreadInfo } from 'lib/types/thread-types'; import Button from '../components/button.react'; import type { DimensionsInfo } from '../redux/dimensions-updater.react'; @@ -46,6 +47,7 @@ +foreground: boolean, +colors: Colors, +styles: typeof unboundStyles, + +threadInfo: ?ThreadInfo, }; type State = { +selections: ?$ReadOnlyArray, @@ -341,16 +343,7 @@ } }); - const selectionURIs = selections.map(({ uri }) => uri); - this.guardedSetState(prevState => ({ - error: null, - selections: [...selections, ...(prevState.selections ?? [])], - queuedMediaURIs: new Set([ - ...selectionURIs, - ...(prevState.queuedMediaURIs ?? []), - ]), - focusedMediaURI: null, - })); + this.sendMedia(selections, this.props.threadInfo); } catch (e) { if (__DEV__) { console.warn(e); @@ -571,7 +564,10 @@ this.sendMedia(queuedSelections); }; - sendMedia(selections: $ReadOnlyArray) { + sendMedia( + selections: $ReadOnlyArray, + threadInfo?: ?ThreadInfo, + ) { if (this.mediaSelected) { return; } @@ -587,10 +583,10 @@ ...timeProps, })); - KeyboardRegistry.onItemSelected( - mediaGalleryKeyboardName, - selectionsWithTime, - ); + KeyboardRegistry.onItemSelected(mediaGalleryKeyboardName, { + selections: selectionsWithTime, + threadInfo, + }); } } @@ -653,7 +649,7 @@ }, }; -function ConnectedMediaGalleryKeyboard() { +function ConnectedMediaGalleryKeyboard(props) { const dimensions = useSelector(state => state.dimensions); const foreground = useIsAppForegrounded(); const colors = useColors(); @@ -664,14 +660,15 @@ foreground={foreground} colors={colors} styles={styles} + {...props} /> ); } -function ReduxMediaGalleryKeyboard() { +function ReduxMediaGalleryKeyboard(props) { return ( - + ); }