@@ -6,8 +6,9 @@ import dayjs from 'dayjs';
66
77import merge from 'lodash/merge' ;
88
9- import type { Attachment } from 'stream-chat' ;
9+ import type { Attachment , PollState } from 'stream-chat' ;
1010
11+ import { useChatContext } from '../../contexts' ;
1112import { useMessageContext } from '../../contexts/messageContext/MessageContext' ;
1213import {
1314 MessageInputContext ,
@@ -22,6 +23,7 @@ import {
2223 TranslationContextValue ,
2324 useTranslationContext ,
2425} from '../../contexts/translationContext/TranslationContext' ;
26+ import { useStateStore } from '../../hooks' ;
2527import { DefaultStreamChatGenerics , FileTypes } from '../../types/types' ;
2628import { getResizedImageUrl } from '../../utils/getResizedImageUrl' ;
2729import { getTrimmedAttachmentTitle } from '../../utils/getTrimmedAttachmentTitle' ;
@@ -31,6 +33,7 @@ import { FileIcon as FileIconDefault } from '../Attachment/FileIcon';
3133import { VideoThumbnail } from '../Attachment/VideoThumbnail' ;
3234import { MessageAvatar as MessageAvatarDefault } from '../Message/MessageSimple/MessageAvatar' ;
3335import { MessageTextContainer } from '../Message/MessageSimple/MessageTextContainer' ;
36+ import { MessageType } from '../MessageList/hooks/useMessageList' ;
3437
3538const styles = StyleSheet . create ( {
3639 container : {
@@ -72,6 +75,16 @@ const styles = StyleSheet.create({
7275 } ,
7376} ) ;
7477
78+ export type ReplySelectorReturnType = {
79+ name ?: string ;
80+ } ;
81+
82+ const selector = < StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics > (
83+ nextValue : PollState < StreamChatGenerics > ,
84+ ) : ReplySelectorReturnType => ( {
85+ name : nextValue . name ,
86+ } ) ;
87+
7588type ReplyPropsWithContext <
7689 StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics ,
7790> = Pick < MessageInputContextValue < StreamChatGenerics > , 'quotedMessage' > &
@@ -134,6 +147,7 @@ const ReplyWithContext = <
134147> (
135148 props : ReplyPropsWithContext < StreamChatGenerics > ,
136149) => {
150+ const { client } = useChatContext ( ) ;
137151 const {
138152 attachmentSize = 40 ,
139153 FileAttachmentIcon,
@@ -167,6 +181,9 @@ const ReplyWithContext = <
167181 } ,
168182 } = useTheme ( ) ;
169183
184+ const poll = client . polls . fromState ( ( quotedMessage as MessageType ) ?. poll_id ?? '' ) ;
185+ const { name : pollName } : ReplySelectorReturnType = useStateStore ( poll ?. state , selector ) ?? { } ;
186+
170187 const messageText = typeof quotedMessage === 'boolean' ? '' : quotedMessage . text || '' ;
171188
172189 const emojiOnlyText = useMemo ( ( ) => {
@@ -262,8 +279,8 @@ const ReplyWithContext = <
262279 text :
263280 quotedMessage . type === 'deleted'
264281 ? `_${ t ( 'Message deleted' ) } _`
265- : quotedMessage . poll
266- ? `📊 ${ quotedMessage . poll . name } `
282+ : pollName
283+ ? `📊 ${ pollName } `
267284 : quotedMessage . text
268285 ? quotedMessage . text . length > 170
269286 ? `${ quotedMessage . text . slice ( 0 , 170 ) } ...`
0 commit comments