Page MenuHomePhabricator

D7514.id25434.diff
No OneTemporary

D7514.id25434.diff

diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js
--- a/native/chat/chat-input-bar.react.js
+++ b/native/chat/chat-input-bar.react.js
@@ -90,7 +90,7 @@
import { NavContext } from '../navigation/navigation-context.js';
import {
type NavigationRoute,
- CameraModalRouteName,
+ ChatCameraModalRouteName,
ImagePasteModalRouteName,
} from '../navigation/route-names.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -1066,8 +1066,8 @@
const openCamera = React.useCallback(() => {
keyboardState?.dismissKeyboard();
- navigation.navigate<'CameraModal'>({
- name: CameraModalRouteName,
+ navigation.navigate<'ChatCameraModal'>({
+ name: ChatCameraModalRouteName,
params: {
presentedFrom: route.key,
thread: threadInfo,
diff --git a/native/media/camera-modal.react.js b/native/media/camera-modal.react.js
--- a/native/media/camera-modal.react.js
+++ b/native/media/camera-modal.react.js
@@ -32,18 +32,16 @@
import { useIsAppForegrounded } from 'lib/shared/lifecycle-utils.js';
import type { PhotoCapture } from 'lib/types/media-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
-import type { ThreadInfo } from 'lib/types/thread-types.js';
import SendMediaButton from './send-media-button.react.js';
import ContentLoading from '../components/content-loading.react.js';
import ConnectedStatusBar from '../connected-status-bar.react.js';
-import { type InputState, InputStateContext } from '../input/input-state.js';
import type { AppNavigationProp } from '../navigation/app-navigator.react.js';
import {
OverlayContext,
type OverlayContextType,
} from '../navigation/overlay-context.js';
-import type { NavigationRoute } from '../navigation/route-names.js';
+import type { OverlayParamList } from '../navigation/route-names.js';
import { updateDeviceCameraInfoActionType } from '../redux/action-types.js';
import { type DimensionsInfo } from '../redux/dimensions-updater.react.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -221,19 +219,16 @@
]);
}
-export type CameraModalParams = {
- +presentedFrom: string,
- +thread: ThreadInfo,
-};
-
type TouchableOpacityInstance = React.AbstractComponent<
React.ElementConfig<typeof TouchableOpacity>,
NativeMethods,
>;
type BaseProps = {
- +navigation: AppNavigationProp<'CameraModal'>,
- +route: NavigationRoute<'CameraModal'>,
+ +handlePhotoCapture: (capture: PhotoCapture) => void,
+ +navigation: $Values<
+ $ObjMapi<OverlayParamList, <K>(K) => AppNavigationProp<K>>,
+ >,
};
type Props = {
...BaseProps,
@@ -244,8 +239,6 @@
+foreground: boolean,
// Redux dispatch functions
+dispatch: Dispatch,
- // withInputState
- +inputState: ?InputState,
// withOverlayContext
+overlayContext: ?OverlayContextType,
};
@@ -927,9 +920,7 @@
this.close();
- const { inputState } = this.props;
- invariant(inputState, 'inputState should be set');
- inputState.sendMultimediaMessage([capture], this.props.route.params.thread);
+ this.props.handlePhotoCapture(capture);
};
clearPendingImage = () => {
@@ -1186,7 +1177,6 @@
const deviceOrientation = useSelector(state => state.deviceOrientation);
const foreground = useIsAppForegrounded();
const overlayContext = React.useContext(OverlayContext);
- const inputState = React.useContext(InputStateContext);
const dispatch = useDispatch();
return (
@@ -1198,7 +1188,6 @@
foreground={foreground}
dispatch={dispatch}
overlayContext={overlayContext}
- inputState={inputState}
/>
);
});
diff --git a/native/media/chat-camera-modal.react.js b/native/media/chat-camera-modal.react.js
new file mode 100644
--- /dev/null
+++ b/native/media/chat-camera-modal.react.js
@@ -0,0 +1,41 @@
+// @flow
+
+import invariant from 'invariant';
+import * as React from 'react';
+
+import type { PhotoCapture } from 'lib/types/media-types.js';
+import type { ThreadInfo } from 'lib/types/thread-types.js';
+
+import CameraModal from './camera-modal.react.js';
+import { InputStateContext } from '../input/input-state.js';
+import type { AppNavigationProp } from '../navigation/app-navigator.react.js';
+import type { NavigationRoute } from '../navigation/route-names.js';
+
+export type ChatCameraModalParams = {
+ +presentedFrom: string,
+ +thread: ThreadInfo,
+};
+
+type Props = {
+ +navigation: AppNavigationProp<'ChatCameraModal'>,
+ +route: NavigationRoute<'ChatCameraModal'>,
+};
+
+function ChatCameraModal(props: Props): React.Node {
+ const { navigation, route } = props;
+ const { thread } = route.params;
+
+ const inputState = React.useContext(InputStateContext);
+
+ const sendPhoto = React.useCallback(
+ (capture: PhotoCapture) => {
+ invariant(inputState, 'inputState should be set');
+ inputState.sendMultimediaMessage([capture], thread);
+ },
+ [inputState, thread],
+ );
+
+ return <CameraModal handlePhotoCapture={sendPhoto} navigation={navigation} />;
+}
+
+export default ChatCameraModal;
diff --git a/native/navigation/app-navigator.react.js b/native/navigation/app-navigator.react.js
--- a/native/navigation/app-navigator.react.js
+++ b/native/navigation/app-navigator.react.js
@@ -21,7 +21,7 @@
ThreadSettingsMemberTooltipModalRouteName,
RelationshipListItemTooltipModalRouteName,
RobotextMessageTooltipModalRouteName,
- CameraModalRouteName,
+ ChatCameraModalRouteName,
VideoPlaybackModalRouteName,
CommunityDrawerNavigatorRouteName,
type ScreenParamList,
@@ -32,7 +32,7 @@
import ThreadSettingsMemberTooltipModal from '../chat/settings/thread-settings-member-tooltip-modal.react.js';
import TextMessageTooltipModal from '../chat/text-message-tooltip-modal.react.js';
import KeyboardStateContainer from '../keyboard/keyboard-state-container.react.js';
-import CameraModal from '../media/camera-modal.react.js';
+import ChatCameraModal from '../media/chat-camera-modal.react.js';
import ImageModal from '../media/image-modal.react.js';
import VideoPlaybackModal from '../media/video-playback-modal.react.js';
import RelationshipListItemTooltipModal from '../profile/relationship-list-item-tooltip-modal.react.js';
@@ -131,7 +131,10 @@
name={RobotextMessageTooltipModalRouteName}
component={RobotextMessageTooltipModal}
/>
- <App.Screen name={CameraModalRouteName} component={CameraModal} />
+ <App.Screen
+ name={ChatCameraModalRouteName}
+ component={ChatCameraModal}
+ />
<App.Screen
name={VideoPlaybackModalRouteName}
component={VideoPlaybackModal}
diff --git a/native/navigation/route-names.js b/native/navigation/route-names.js
--- a/native/navigation/route-names.js
+++ b/native/navigation/route-names.js
@@ -22,7 +22,7 @@
import type { SidebarListModalParams } from '../chat/sidebar-list-modal.react.js';
import type { SubchannelListModalParams } from '../chat/subchannels-list-modal.react.js';
import type { TextMessageTooltipModalParams } from '../chat/text-message-tooltip-modal.react.js';
-import type { CameraModalParams } from '../media/camera-modal.react.js';
+import type { ChatCameraModalParams } from '../media/chat-camera-modal.react.js';
import type { ImageModalParams } from '../media/image-modal.react.js';
import type { VideoPlaybackModalParams } from '../media/video-playback-modal.react.js';
import type { CustomServerModalParams } from '../profile/custom-server-modal.react.js';
@@ -37,7 +37,7 @@
export const BlockListRouteName = 'BlockList';
export const BuildInfoRouteName = 'BuildInfo';
export const CalendarRouteName = 'Calendar';
-export const CameraModalRouteName = 'CameraModal';
+export const ChatCameraModalRouteName = 'ChatCameraModal';
export const ChatRouteName = 'Chat';
export const ChatThreadListRouteName = 'ChatThreadList';
export const ColorSelectorModalRouteName = 'ColorSelectorModal';
@@ -113,7 +113,7 @@
+CommunityDrawerNavigator: void,
+ImageModal: ImageModalParams,
+ActionResultModal: ActionResultModalParams,
- +CameraModal: CameraModalParams,
+ +ChatCameraModal: ChatCameraModalParams,
+VideoPlaybackModal: VideoPlaybackModalParams,
...TooltipModalParamList,
};

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 30, 3:50 PM (21 h, 30 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2601521
Default Alt Text
D7514.id25434.diff (8 KB)

Event Timeline