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'; @@ -46,11 +47,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; keyboardState.dismissKeyboard(); - const mediaGalleryThread = keyboardState.getMediaGalleryThread(); + + const { selections, threadInfo: mediaGalleryThread } = result; if (!mediaGalleryThread) { return; } 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'; @@ -40,7 +41,11 @@ useNativeDriver: true, }; +type BaseProps = { + +threadInfo: ?ThreadInfo, +}; type Props = { + ...BaseProps, // Redux state +dimensions: DimensionsInfo, +foreground: boolean, @@ -341,16 +346,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); } catch (e) { if (__DEV__) { console.warn(e); @@ -587,10 +583,10 @@ ...timeProps, })); - KeyboardRegistry.onItemSelected( - mediaGalleryKeyboardName, - selectionsWithTime, - ); + KeyboardRegistry.onItemSelected(mediaGalleryKeyboardName, { + selections: selectionsWithTime, + threadInfo: this.props.threadInfo, + }); } } @@ -653,7 +649,7 @@ }, }; -function ConnectedMediaGalleryKeyboard() { +function ConnectedMediaGalleryKeyboard(props: BaseProps) { 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: BaseProps) { return ( - + ); }