1- import React , { useCallback , useMemo , useState } from 'react' ;
1+ import React , { useCallback , useState } from 'react' ;
22import { Modal , SafeAreaView , StyleSheet , Text , View } from 'react-native' ;
33
4- import { Poll , PollOption , PollVote as PollVoteClass , VotingVisibility } from 'stream-chat' ;
4+ import { Poll , PollOption , PollVote as PollVoteClass } from 'stream-chat' ;
55
66import { PollOptionFullResults } from './PollOptionFullResults' ;
7+ import { PollVote } from './PollVote' ;
78
89import {
910 useOwnCapabilitiesContext ,
@@ -12,8 +13,6 @@ import {
1213 useTranslationContext ,
1314} from '../../../../contexts' ;
1415import type { DefaultStreamChatGenerics } from '../../../../types/types' ;
15- import { getDateString } from '../../../../utils/i18n/getDateString' ;
16- import { Avatar } from '../../../Avatar/Avatar' ;
1716import { MessageType } from '../../../MessageList/hooks/useMessageList' ;
1817import { usePollState } from '../../hooks/usePollState' ;
1918import { GenericPollButton } from '../Button' ;
@@ -86,51 +85,6 @@ export type PollResultItemProps<
8685 option : PollOption < StreamChatGenerics > ;
8786} ;
8887
89- export const PollVote = ( { vote } : { vote : PollVoteClass } ) => {
90- const { t, tDateTimeParser } = useTranslationContext ( ) ;
91- const { votingVisibility } = usePollState ( ) ;
92- const {
93- theme : {
94- colors : { black, text_low_emphasis } ,
95- poll : {
96- results : {
97- vote : { container, dateText, userName } ,
98- } ,
99- } ,
100- } ,
101- } = useTheme ( ) ;
102-
103- const dateString = useMemo (
104- ( ) =>
105- getDateString ( {
106- date : vote . created_at ,
107- t,
108- tDateTimeParser,
109- timestampTranslationKey : 'timestamp/PollVote' ,
110- } ) ,
111- [ vote . created_at , t , tDateTimeParser ] ,
112- ) ;
113-
114- const isAnonymous = useMemo (
115- ( ) => votingVisibility === VotingVisibility . anonymous ,
116- [ votingVisibility ] ,
117- ) ;
118-
119- return (
120- < View style = { [ styles . voteContainer , container ] } >
121- < View style = { { flexDirection : 'row' } } >
122- { ! isAnonymous && vote . user ?. image ? (
123- < Avatar image = { vote . user . image as string } key = { vote . id } size = { 20 } />
124- ) : null }
125- < Text style = { [ styles . voteUserName , { color : black } , userName ] } >
126- { isAnonymous ? t < string > ( 'Anonymous' ) : vote . user ?. name }
127- </ Text >
128- </ View >
129- < Text style = { [ styles . voteDate , { color : text_low_emphasis } , dateText ] } > { dateString } </ Text >
130- </ View >
131- ) ;
132- } ;
133-
13488const PollResultsVoteItem = ( vote : PollVoteClass ) => (
13589 < PollVote key = { `results_vote_${ vote . id } ` } vote = { vote } />
13690) ;
@@ -177,13 +131,5 @@ const styles = StyleSheet.create({
177131 } ,
178132 headerContainer : { flexDirection : 'row' , justifyContent : 'space-between' } ,
179133 title : { flex : 1 , fontSize : 16 , fontWeight : '500' } ,
180- voteContainer : {
181- flexDirection : 'row' ,
182- justifyContent : 'space-between' ,
183- marginBottom : 8 ,
184- paddingVertical : 8 ,
185- } ,
186134 voteCount : { fontSize : 16 , marginLeft : 16 } ,
187- voteDate : { fontSize : 14 } ,
188- voteUserName : { fontSize : 14 , marginLeft : 2 } ,
189135} ) ;
0 commit comments