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 @@ -270,6 +270,7 @@ export type RobotextChatMessageInfoItem = { +itemType: 'message', + +messageInfoType: 'robotext', +messageInfo: RobotextMessageInfo, +startsConversation: boolean, +startsCluster: boolean, @@ -282,6 +283,7 @@ | RobotextChatMessageInfoItem | { +itemType: 'message', + +messageInfoType: 'composable', +messageInfo: ComposableMessageInfo, +localMessageInfo: ?LocalMessageInfo, +startsConversation: boolean, @@ -458,6 +460,7 @@ messageStore.local[messageKey(originalMessageInfo)]; chatMessageItems.push({ itemType: 'message', + messageInfoType: 'composable', messageInfo: originalMessageInfo, localMessageInfo, startsConversation, @@ -479,6 +482,7 @@ ); chatMessageItems.push({ itemType: 'message', + messageInfoType: 'robotext', messageInfo: originalMessageInfo, startsConversation, startsCluster, diff --git a/native/chat/chat-item-height-measurer.react.js b/native/chat/chat-item-height-measurer.react.js --- a/native/chat/chat-item-height-measurer.react.js +++ b/native/chat/chat-item-height-measurer.react.js @@ -120,25 +120,30 @@ contentHeight: height, reactions: item.reactions, }; - } else { - invariant( - typeof item.robotext === 'string', - "Flow can't handle our fancy types :(", - ); - return { - itemType: 'message', - messageShapeType: 'robotext', - messageInfo, - threadInfo, - startsConversation: item.startsConversation, - startsCluster: item.startsCluster, - endsCluster: item.endsCluster, - threadCreatedFromMessage: item.threadCreatedFromMessage, - robotext: item.robotext, - contentHeight: height, - reactions: item.reactions, - }; } + invariant( + item.messageInfoType !== 'composable', + 'ChatItemHeightMeasurer was handed a messageInfoType=composable, but ' + + `does not know how to handle MessageType ${messageInfo.type}`, + ); + invariant( + item.messageInfoType === 'robotext', + 'ChatItemHeightMeasurer was handed a messageInfoType that it does ' + + `not recognize: ${item.messageInfoType}`, + ); + return { + itemType: 'message', + messageShapeType: 'robotext', + messageInfo, + threadInfo, + startsConversation: item.startsConversation, + startsCluster: item.startsCluster, + endsCluster: item.endsCluster, + threadCreatedFromMessage: item.threadCreatedFromMessage, + robotext: item.robotext, + contentHeight: height, + reactions: item.reactions, + }; }, [composedMessageMaxWidth, inputStatePendingUploads, threadInfo], );