diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js --- a/lib/selectors/chat-selectors.js +++ b/lib/selectors/chat-selectors.js @@ -283,21 +283,22 @@ +threadCreatedFromMessage: ?ThreadInfo, +reactions: ReactionInfo, }; +export type ComposedChatMessageInfoItem = { + +itemType: 'message', + +messageInfoType: 'composable', + +messageInfo: ComposableMessageInfo, + +localMessageInfo: ?LocalMessageInfo, + +startsConversation: boolean, + +startsCluster: boolean, + endsCluster: boolean, + +threadCreatedFromMessage: ?ThreadInfo, + +reactions: ReactionInfo, + +hasBeenEdited: boolean, + +isPinned: boolean, +}; export type ChatMessageInfoItem = | RobotextChatMessageInfoItem - | { - +itemType: 'message', - +messageInfoType: 'composable', - +messageInfo: ComposableMessageInfo, - +localMessageInfo: ?LocalMessageInfo, - +startsConversation: boolean, - +startsCluster: boolean, - endsCluster: boolean, - +threadCreatedFromMessage: ?ThreadInfo, - +reactions: ReactionInfo, - +hasBeenEdited: boolean, - +isPinned: boolean, - }; + | ComposedChatMessageInfoItem; export type ChatMessageItem = { itemType: 'loader' } | ChatMessageInfoItem; export type ReactionInfo = { +[reaction: string]: MessageReactionInfo }; 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 @@ -9,7 +9,7 @@ } from 'react-feather'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; -import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import { type ComposedChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { getMessageLabel } from 'lib/shared/edit-messages-utils.js'; import { assertComposableMessageType } from 'lib/types/message-types.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; @@ -48,7 +48,7 @@ ]; type Props = { - +item: ChatMessageInfoItem, + +item: ComposedChatMessageInfoItem, +threadInfo: ThreadInfo, +shouldDisplayPinIndicator: boolean, +sendFailed: boolean, diff --git a/web/chat/edit-message-provider.js b/web/chat/edit-message-provider.js --- a/web/chat/edit-message-provider.js +++ b/web/chat/edit-message-provider.js @@ -4,7 +4,7 @@ import * as React from 'react'; import ModalOverlay from 'lib/components/modal-overlay.react.js'; -import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import type { ComposedChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; import { EditTextMessage } from './edit-text-message.react.js'; @@ -17,7 +17,7 @@ }; export type EditState = { - +messageInfo: ChatMessageInfoItem, + +messageInfo: ComposedChatMessageInfoItem, +threadInfo: ThreadInfo, +editedMessageDraft: ?string, +isError: boolean, diff --git a/web/chat/edit-text-message.react.js b/web/chat/edit-text-message.react.js --- a/web/chat/edit-text-message.react.js +++ b/web/chat/edit-text-message.react.js @@ -5,7 +5,7 @@ import { useCallback } from 'react'; import { XCircle as XCircleIcon } from 'react-feather'; -import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import type { ComposedChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { useEditMessage } from 'lib/shared/edit-messages-utils.js'; import { trimMessage } from 'lib/shared/message-utils.js'; import type { ThreadInfo } from 'lib/types/minimally-encoded-thread-permissions-types.js'; @@ -19,7 +19,7 @@ import Button from '../components/button.react.js'; type Props = { - +item: ChatMessageInfoItem, + +item: ComposedChatMessageInfoItem, +threadInfo: ThreadInfo, +background: boolean, }; diff --git a/web/chat/failed-send.react.js b/web/chat/failed-send.react.js --- a/web/chat/failed-send.react.js +++ b/web/chat/failed-send.react.js @@ -3,7 +3,7 @@ import invariant from 'invariant'; import * as React from 'react'; -import { type ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; +import { type ComposedChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; import { threadInfoSelector } from 'lib/selectors/thread-selectors.js'; import { messageID } from 'lib/shared/message-utils.js'; import { messageTypes } from 'lib/types/message-types-enum.js'; @@ -21,7 +21,7 @@ import { useSelector } from '../redux/redux-utils.js'; type BaseProps = { - +item: ChatMessageInfoItem, + +item: ComposedChatMessageInfoItem, +threadInfo: ThreadInfo, }; type Props = { diff --git a/web/chat/message.react.js b/web/chat/message.react.js --- a/web/chat/message.react.js +++ b/web/chat/message.react.js @@ -36,17 +36,21 @@ let message; if ( + item.messageInfoType === 'composable' && item.messageInfo.id && editState?.messageInfo.messageInfo?.id === item.messageInfo.id ) { message = ( ); - } else if (item.messageInfo.type === messageTypes.TEXT) { + } else if ( + item.messageInfoType === 'composable' && + item.messageInfo.type === messageTypes.TEXT + ) { message = ( ); } else if ( - item.messageInfo.type === messageTypes.IMAGES || - item.messageInfo.type === messageTypes.MULTIMEDIA + item.messageInfoType === 'composable' && + (item.messageInfo.type === messageTypes.IMAGES || + item.messageInfo.type === messageTypes.MULTIMEDIA) ) { message = ( ; const onClickEdit = () => { const callback = (maxHeight: number) =>