diff --git a/native/chat/inner-text-message.react.js b/native/chat/inner-text-message.react.js --- a/native/chat/inner-text-message.react.js +++ b/native/chat/inner-text-message.react.js @@ -5,6 +5,7 @@ import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native'; import Animated from 'react-native-reanimated'; +import { messageKey } from 'lib/shared/message-utils'; import { colorIsDark } from 'lib/shared/thread-utils'; import GestureTouchableOpacity from '../components/gesture-touchable-opacity.react'; @@ -13,6 +14,7 @@ import { useColors, colors } from '../themes/colors'; import type { ChatTextMessageInfoItemWithHeight } from '../types/chat-types'; import { useComposedMessageMaxWidth } from './composed-message-width'; +import { MessageContext } from './message-context.react'; import { MessageListContext } from './message-list-types'; import { allCorners, @@ -101,6 +103,16 @@ return [styles.text, textStyle]; }, [darkColor]); + // We use a MessageContext to allow MarkdownLink and MarkdownSpoiler + // to access the messageKey so it is 'self-aware' + const key = messageKey(item.messageInfo); + const messageContextValue = React.useMemo( + () => ({ + messageKey: key, + }), + [key], + ); + const message = ( @@ -111,9 +123,11 @@ style={[styles.message, cornerStyle]} animatedStyle={messageStyle} > - - {text} - + + + {text} + + diff --git a/native/chat/text-message.react.js b/native/chat/text-message.react.js --- a/native/chat/text-message.react.js +++ b/native/chat/text-message.react.js @@ -25,7 +25,6 @@ import type { ChatNavigationProp } from './chat.react'; import ComposedMessage from './composed-message.react'; import { InnerTextMessage } from './inner-text-message.react'; -import { MessageContext } from './message-context.react'; import textMessageSendFailed from './text-message-send-failed'; import { getMessageTooltipKey } from './utils'; @@ -234,28 +233,17 @@ props.item.messageInfo, ); - // We use a MessageContext to allow MarkdownLink and MarkdownSpoiler - // to access the messageKey so it is 'self-aware' - const contextValue = React.useMemo( - () => ({ - messageKey: key, - }), - [key], - ); - React.useEffect(() => clearMarkdownContextData, [clearMarkdownContextData]); return ( - - - + ); }, );