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,21 @@
? availableTooltipPositionsForViewerMessage
: availableTooltipPositionsForNonViewerMessage;
+ const messageState = !this.props.canReply
+ ? { canReply: false }
+ : {
+ canReply: true,
+ inputState: this.props.inputState,
+ setMouseOverMessagePosition: this.props.setMouseOverMessagePosition,
+ };
+
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,31 @@
type TooltipType = 'sidebar' | 'reply';
+type MessageStateType =
+ | { +canReply: false }
+ | {
+ +canReply: true,
+ +inputState: ?InputState,
+ +setMouseOverMessagePosition: (
+ messagePositionInfo: MessagePositionInfo,
+ ) => void,
+ };
+
type MessageTooltipProps = {
+threadInfo: ThreadInfo,
+item: ChatMessageInfoItem,
+availableTooltipPositions: $ReadOnlyArray,
- +setMouseOverMessagePosition?: (
- messagePositionInfo: MessagePositionInfo,
- ) => void,
+ +messageState: MessageStateType,
+mouseOverMessagePosition: OnMessagePositionWithContainerInfo,
- +canReply?: boolean,
- +inputState?: ?InputState,
};
+
function MessageTooltip(props: MessageTooltipProps): React.Node {
const {
threadInfo,
item,
availableTooltipPositions,
- setMouseOverMessagePosition,
mouseOverMessagePosition,
- canReply,
- inputState,
+ messageState,
} = props;
const { containerPosition } = mouseOverMessagePosition;
@@ -115,12 +120,10 @@
);
const onReplyButtonClick = React.useCallback(() => {
- invariant(
- setMouseOverMessagePosition,
- 'setMouseOverMessagePosition should be set if replyButton exists',
- );
- setMouseOverMessagePosition({ type: 'off', item: item });
- }, [item, setMouseOverMessagePosition]);
+ if (messageState.canReply) {
+ messageState.setMouseOverMessagePosition({ type: 'off', item: item });
+ }
+ }, [item, messageState]);
let tooltipText = '';
if (activeTooltip === 'reply') {
@@ -146,12 +149,12 @@
}
let replyButton;
- if (canReply) {
- invariant(inputState, 'inputState must be set if replyButton exists');
+ if (messageState.canReply) {
invariant(
- mouseOverMessagePosition,
- 'mouseOverMessagePosition must be set if replyButton exists',
+ messageState.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}
+ messageState={{ canReply: false }}
/>
);
}