diff --git a/web/chat/composed-message.react.js b/web/chat/composed-message.react.js
--- a/web/chat/composed-message.react.js
+++ b/web/chat/composed-message.react.js
@@ -128,15 +128,23 @@
? availableTooltipPositionsForViewerMessage
: availableTooltipPositionsForNonViewerMessage;
+ const messageReplyProps = this.props.canReply
+ ? {
+ canReply: true,
+ inputState: this.props.inputState,
+ setMouseOverMessagePosition: this.props.setMouseOverMessagePosition,
+ }
+ : {
+ canReply: false,
+ };
+
messageTooltip = (
);
}
diff --git a/web/chat/message-tooltip.react.js b/web/chat/message-tooltip.react.js
--- a/web/chat/message-tooltip.react.js
+++ b/web/chat/message-tooltip.react.js
@@ -36,26 +36,32 @@
type TooltipType = 'sidebar' | 'reply';
-type MessageTooltipProps = {
+type BaseMessageTooltipProps = {
+threadInfo: ThreadInfo,
+item: ChatMessageInfoItem,
+availableTooltipPositions: $ReadOnlyArray,
- +setMouseOverMessagePosition?: (
- messagePositionInfo: MessagePositionInfo,
- ) => void,
+mouseOverMessagePosition: OnMessagePositionWithContainerInfo,
- +canReply?: boolean,
- +inputState?: ?InputState,
};
+type MessageTooltipProps =
+ | {
+ +canReply: false,
+ ...BaseMessageTooltipProps,
+ }
+ | {
+ +canReply: true,
+ ...BaseMessageTooltipProps,
+ +inputState: ?InputState,
+ +setMouseOverMessagePosition: (
+ messagePositionInfo: MessagePositionInfo,
+ ) => void,
+ };
function MessageTooltip(props: MessageTooltipProps): React.Node {
const {
threadInfo,
item,
availableTooltipPositions,
- setMouseOverMessagePosition,
mouseOverMessagePosition,
canReply,
- inputState,
} = props;
const { containerPosition } = mouseOverMessagePosition;
@@ -114,12 +120,15 @@
[onPendingSidebarOpen, onThreadOpen, threadCreatedFromMessage],
);
+ const setMouseOverMessagePosition = props.canReply
+ ? props.setMouseOverMessagePosition
+ : null;
+
const onReplyButtonClick = React.useCallback(() => {
- invariant(
- setMouseOverMessagePosition,
- 'setMouseOverMessagePosition should be set if replyButton exists',
- );
- setMouseOverMessagePosition({ type: 'off', item: item });
+ setMouseOverMessagePosition?.({
+ type: 'off',
+ item: item,
+ });
}, [item, setMouseOverMessagePosition]);
let tooltipText = '';
@@ -147,11 +156,7 @@
let replyButton;
if (canReply) {
- invariant(inputState, 'inputState must be set if replyButton exists');
- invariant(
- mouseOverMessagePosition,
- 'mouseOverMessagePosition must be set if replyButton exists',
- );
+ invariant(props.inputState, 'inputState must be set if replyButton exists');
replyButton = (
{activeTooltip === 'reply' ? tooltipMenu : null}
diff --git a/web/chat/robotext-message.react.js b/web/chat/robotext-message.react.js
--- a/web/chat/robotext-message.react.js
+++ b/web/chat/robotext-message.react.js
@@ -71,6 +71,7 @@
item={item}
mouseOverMessagePosition={this.props.mouseOverMessagePosition}
availableTooltipPositions={availableTooltipPositionsForRobotext}
+ canReply={false}
/>
);
}