11import { FlatList , Pressable , StyleSheet , Text , View } from 'react-native' ;
22import { DraftsIcon } from '../icons/DraftIcon' ;
33import {
4- MessagePreview ,
54 useChatContext ,
65 useStateStore ,
76 useTheme ,
8- useTranslationContext ,
7+ useMessagePreviewText ,
98} from 'stream-chat-react-native' ;
109import { DraftManagerState , DraftsManager } from '../utils/DraftsManager' ;
1110import { useCallback , useEffect , useMemo } from 'react' ;
1211import dayjs from 'dayjs' ;
1312import { useIsFocused , useNavigation } from '@react-navigation/native' ;
1413import { ChannelResponse , DraftMessage , DraftResponse , MessageResponseBase } from 'stream-chat' ;
15- import { getPreviewFromMessage } from '../utils/getPreviewOfMessage' ;
1614
1715export type DraftItemProps = {
1816 type ?: 'channel' | 'thread' ;
@@ -31,7 +29,7 @@ export const DraftItem = ({ type, channel, date, message, thread }: DraftItemPro
3129 } = useTheme ( ) ;
3230 const navigation = useNavigation ( ) ;
3331 const { client } = useChatContext ( ) ;
34- const { t } = useTranslationContext ( ) ;
32+ const messagePreviewText = useMessagePreviewText ( { message } ) ;
3533 const channelName = channel ?. name ? channel . name : 'Channel' ;
3634
3735 const onNavigationHandler = async ( ) => {
@@ -50,10 +48,6 @@ export const DraftItem = ({ type, channel, date, message, thread }: DraftItemPro
5048 }
5149 } ;
5250
53- const previews = useMemo ( ( ) => {
54- return getPreviewFromMessage ( { message, t } ) ;
55- } , [ message , t ] ) ;
56-
5751 return (
5852 < Pressable
5953 style = { ( { pressed } ) => [ styles . itemContainer , { opacity : pressed ? 0.8 : 1 } ] }
@@ -69,7 +63,7 @@ export const DraftItem = ({ type, channel, date, message, thread }: DraftItemPro
6963 < View style = { styles . icon } >
7064 < DraftsIcon />
7165 </ View >
72- < MessagePreview previews = { previews } / >
66+ < Text style = { styles . text } > { messagePreviewText } </ Text >
7367 </ View >
7468 </ Pressable >
7569 ) ;
0 commit comments