Page MenuHomePhabricator

D13685.id45126.diff
No OneTemporary

D13685.id45126.diff

diff --git a/lib/shared/chat-message-item-utils.js b/lib/shared/chat-message-item-utils.js
--- a/lib/shared/chat-message-item-utils.js
+++ b/lib/shared/chat-message-item-utils.js
@@ -40,6 +40,12 @@
return longAbsoluteDate(item.messageInfo.time);
}
+function chatMessageItemEngagementTargetMessageInfo(
+ item: BaseChatMessageInfoItem,
+): ComposableMessageInfo | RobotextMessageInfo {
+ return item.messageInfo;
+}
+
function chatMessageItemHasNonViewerMessage(
item: BaseChatMessageItem,
viewerID: ?string,
@@ -70,6 +76,7 @@
export {
chatMessageItemKey,
chatMessageInfoItemTimestamp,
+ chatMessageItemEngagementTargetMessageInfo,
chatMessageItemHasNonViewerMessage,
chatMessageItemHasEngagement,
};
diff --git a/lib/shared/sidebar-utils.js b/lib/shared/sidebar-utils.js
--- a/lib/shared/sidebar-utils.js
+++ b/lib/shared/sidebar-utils.js
@@ -13,6 +13,7 @@
userIsMember,
} from './thread-utils.js';
import type { ChatMessageInfoItem } from '../selectors/chat-selectors.js';
+import { chatMessageItemEngagementTargetMessageInfo } from '../shared/chat-message-item-utils.js';
import { messageTypes } from '../types/message-types-enum.js';
import type {
RobotextMessageInfo,
@@ -229,9 +230,11 @@
threadInfo: ThreadInfo,
messageItem: ChatMessageInfoItem,
): boolean {
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(messageItem);
const canCreateSidebarFromMessage = useCanCreateSidebarFromMessage(
threadInfo,
- messageItem.messageInfo,
+ engagementTargetMessageInfo,
);
return !!messageItem.threadCreatedFromMessage || canCreateSidebarFromMessage;
}
diff --git a/native/chat/robotext-message-tooltip-button.react.js b/native/chat/robotext-message-tooltip-button.react.js
--- a/native/chat/robotext-message-tooltip-button.react.js
+++ b/native/chat/robotext-message-tooltip-button.react.js
@@ -3,6 +3,7 @@
import * as React from 'react';
import Animated from 'react-native-reanimated';
+import { chatMessageItemEngagementTargetMessageInfo } from 'lib/shared/chat-message-item-utils.js';
import {
useViewerAlreadySelectedMessageReactions,
useCanCreateReactionFromMessage,
@@ -66,14 +67,20 @@
};
}, [initialCoordinates.height, initialCoordinates.x, progress, windowWidth]);
- const { messageInfo, threadInfo, reactions } = item;
+ const { threadInfo, reactions } = item;
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
const canCreateReactionFromMessage = useCanCreateReactionFromMessage(
threadInfo,
- messageInfo,
+ engagementTargetMessageInfo,
);
- const sendReaction = useSendReaction(messageInfo.id, threadInfo, reactions);
+ const sendReaction = useSendReaction(
+ engagementTargetMessageInfo?.id,
+ threadInfo,
+ reactions,
+ );
const [emojiPickerOpen, setEmojiPickerOpen] = React.useState<boolean>(false);
const openEmojiPicker = React.useCallback(() => {
diff --git a/native/chat/robotext-message.react.js b/native/chat/robotext-message.react.js
--- a/native/chat/robotext-message.react.js
+++ b/native/chat/robotext-message.react.js
@@ -7,6 +7,7 @@
import {
chatMessageItemKey,
chatMessageItemHasEngagement,
+ chatMessageItemEngagementTargetMessageInfo,
} from 'lib/shared/chat-message-item-utils.js';
import { useCanCreateSidebarFromMessage } from 'lib/shared/sidebar-utils.js';
@@ -62,12 +63,14 @@
}
const styles = useStyles(unboundStyles);
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
let inlineEngagement = null;
if (chatMessageItemHasEngagement(item, item.threadInfo.id)) {
inlineEngagement = (
<View style={styles.sidebar}>
<InlineEngagement
- messageInfo={item.messageInfo}
+ messageInfo={engagementTargetMessageInfo}
threadInfo={item.threadInfo}
sidebarThreadInfo={item.threadCreatedFromMessage}
reactions={item.reactions}
@@ -93,7 +96,7 @@
const canCreateSidebarFromMessage = useCanCreateSidebarFromMessage(
item.threadInfo,
- item.messageInfo,
+ engagementTargetMessageInfo,
);
const visibleEntryIDs = React.useMemo(() => {
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
@@ -5,6 +5,7 @@
import { type RobotextChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
import { threadInfoSelector } from 'lib/selectors/thread-selectors.js';
+import { chatMessageItemEngagementTargetMessageInfo } from 'lib/shared/chat-message-item-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import type { Dispatch } from 'lib/types/redux-types.js';
import {
@@ -41,10 +42,12 @@
const { item, threadInfo } = props;
const { threadCreatedFromMessage, reactions } = item;
if (threadCreatedFromMessage || Object.keys(reactions).length > 0) {
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
inlineEngagement = (
<div className={css.sidebarMarginTop}>
<InlineEngagement
- messageInfo={item.messageInfo}
+ messageInfo={engagementTargetMessageInfo}
threadInfo={threadInfo}
sidebarThreadInfo={threadCreatedFromMessage}
reactions={reactions}
diff --git a/web/modals/chat/toggle-pin-modal.react.js b/web/modals/chat/toggle-pin-modal.react.js
--- a/web/modals/chat/toggle-pin-modal.react.js
+++ b/web/modals/chat/toggle-pin-modal.react.js
@@ -9,6 +9,7 @@
} from 'lib/actions/message-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
+import { chatMessageItemEngagementTargetMessageInfo } from 'lib/shared/chat-message-item-utils.js';
import { modifyItemForResultScreen } from 'lib/shared/message-utils.js';
import type { RawMessageInfo } from 'lib/types/message-types.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
@@ -26,7 +27,7 @@
function TogglePinModal(props: TogglePinModalProps): React.Node {
const { item, threadInfo } = props;
- const { messageInfo, isPinned } = item;
+ const { isPinned } = item;
const { popModal } = useModalContext();
const callToggleMessagePin = useToggleMessagePin();
@@ -71,11 +72,17 @@
return modifyItemForResultScreen(strippedItem);
}, [item]);
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
+ const engagementTargetMessageID = engagementTargetMessageInfo?.id;
const onClick = React.useCallback(() => {
const createToggleMessagePinPromise = async () => {
- invariant(messageInfo.id, 'messageInfo.id should be defined');
+ invariant(
+ engagementTargetMessageID,
+ 'engagement target messageID should be defined',
+ );
const result = await callToggleMessagePin({
- messageID: messageInfo.id,
+ messageID: engagementTargetMessageID,
action: modalInfo.action,
});
return ({
@@ -96,7 +103,7 @@
modalInfo,
callToggleMessagePin,
dispatchActionPromise,
- messageInfo.id,
+ engagementTargetMessageID,
popModal,
]);
diff --git a/web/tooltips/message-tooltip.react.js b/web/tooltips/message-tooltip.react.js
--- a/web/tooltips/message-tooltip.react.js
+++ b/web/tooltips/message-tooltip.react.js
@@ -6,6 +6,7 @@
import * as React from 'react';
import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
+import { chatMessageItemEngagementTargetMessageInfo } from 'lib/shared/chat-message-item-utils.js';
import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js';
import css from './message-tooltip.css';
@@ -42,7 +43,7 @@
item,
threadInfo,
} = props;
- const { messageInfo, reactions } = item;
+ const { reactions } = item;
const { alignment = 'left' } = tooltipPositionStyle;
@@ -169,7 +170,13 @@
};
}, [emojiKeyboardPosition]);
- const sendReaction = useSendReaction(messageInfo.id, threadInfo, reactions);
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
+ const sendReaction = useSendReaction(
+ engagementTargetMessageInfo?.id,
+ threadInfo,
+ reactions,
+ );
const onEmojiSelect = React.useCallback(
(emoji: { +native: string, ... }) => {
diff --git a/web/tooltips/tooltip-action-utils.js b/web/tooltips/tooltip-action-utils.js
--- a/web/tooltips/tooltip-action-utils.js
+++ b/web/tooltips/tooltip-action-utils.js
@@ -10,7 +10,10 @@
ChatMessageInfoItem,
ReactionInfo,
} from 'lib/selectors/chat-selectors.js';
-import { chatMessageInfoItemTimestamp } from 'lib/shared/chat-message-item-utils.js';
+import {
+ chatMessageInfoItemTimestamp,
+ chatMessageItemEngagementTargetMessageInfo,
+} from 'lib/shared/chat-message-item-utils.js';
import { useCanEditMessage } from 'lib/shared/edit-messages-utils.js';
import { createMessageReply } from 'lib/shared/message-utils.js';
import { useCanCreateReactionFromMessage } from 'lib/shared/reaction-utils.js';
@@ -280,9 +283,14 @@
threadInfo: ThreadInfo,
): ?MessageTooltipAction {
const { pushModal } = useModalContext();
- const { messageInfo, isPinned } = item;
+ const { isPinned } = item;
- const canTogglePin = useCanToggleMessagePin(messageInfo, threadInfo);
+ const engagementTargetMessageInfo =
+ chatMessageItemEngagementTargetMessageInfo(item);
+ const canTogglePin = useCanToggleMessagePin(
+ engagementTargetMessageInfo,
+ threadInfo,
+ );
const inputState = React.useContext(InputStateContext);

File Metadata

Mime Type
text/plain
Expires
Wed, Oct 30, 11:13 PM (12 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2389708
Default Alt Text
D13685.id45126.diff (9 KB)

Event Timeline