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,17 +128,27 @@
? availableTooltipPositionsForViewerMessage
: availableTooltipPositionsForNonViewerMessage;
- messageTooltip = (
-
- );
+ const messageTooltipProps = {
+ threadInfo,
+ item,
+ availableTooltipPositions,
+ mouseOverMessagePosition: this.props.mouseOverMessagePosition,
+ };
+
+ if (this.props.canReply) {
+ messageTooltip = (
+
+ );
+ } else {
+ messageTooltip = (
+
+ );
+ }
}
let messageTooltipLinks;
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 =
+ | {
+ ...BaseMessageTooltipProps,
+ +canReply: false,
+ }
+ | {
+ ...BaseMessageTooltipProps,
+ +canReply: true,
+ +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}
/>
);
}