Page MenuHomePhabricator

D6556.id21938.diff
No OneTemporary

D6556.id21938.diff

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<typeof TextInput>,
+ +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 (
<KeyboardAccessoryView
kbInputRef={this.props.textInputRef}
kbComponent={kbComponent}
- kbInitialProps={this.props.styles.kbInitialProps}
+ kbInitialProps={kbInitialProps}
onItemSelected={this.onMediaGalleryItemSelected}
onKeyboardResigned={this.hideMediaGallery}
manageScrollView={false}
@@ -60,11 +66,15 @@
onMediaGalleryItemSelected = async (
keyboardName: string,
- selections: $ReadOnlyArray<MediaLibrarySelection>,
+ result: {
+ selections: $ReadOnlyArray<MediaLibrarySelection>,
+ 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<MediaLibrarySelection>,
@@ -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<MediaLibrarySelection>) {
+ sendMedia(
+ selections: $ReadOnlyArray<MediaLibrarySelection>,
+ 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 (
<Provider store={store}>
- <ConnectedMediaGalleryKeyboard />
+ <ConnectedMediaGalleryKeyboard {...props} />
</Provider>
);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 15, 6:32 PM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495084
Default Alt Text
D6556.id21938.diff (4 KB)

Event Timeline