@@ -10,7 +10,13 @@ import { PollAllOptions } from './PollOption';
1010
1111import { PollOptionFullResults , PollResults } from './PollResults' ;
1212
13- import { useChatContext , usePollContext , useTheme , useTranslationContext } from '../../../contexts' ;
13+ import {
14+ useChatContext ,
15+ useOwnCapabilitiesContext ,
16+ usePollContext ,
17+ useTheme ,
18+ useTranslationContext ,
19+ } from '../../../contexts' ;
1420import { Check } from '../../../icons' ;
1521import type { DefaultStreamChatGenerics } from '../../../types/types' ;
1622import { MessageType } from '../../MessageList/hooks/useMessageList' ;
@@ -322,6 +328,7 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
322328
323329export const VoteButton = ( { onPress, option } : PollVoteButtonProps & { option : PollOption } ) => {
324330 const { is_closed, ownVotesByOptionId } = usePollState ( ) ;
331+ const ownCapabilities = useOwnCapabilitiesContext ( ) ;
325332
326333 const {
327334 theme : {
@@ -334,7 +341,7 @@ export const VoteButton = ({ onPress, option }: PollVoteButtonProps & { option:
334341 } ,
335342 } = useTheme ( ) ;
336343
337- return ! is_closed ? (
344+ return ownCapabilities . castPollVote && ! is_closed ? (
338345 < TouchableOpacity
339346 onPress = { onPress }
340347 style = { [
@@ -359,6 +366,7 @@ export const ShowAllVotesButton = (props: PollButtonProps & { option: PollOption
359366 const { t } = useTranslationContext ( ) ;
360367 const { message, poll } = usePollContext ( ) ;
361368 const { vote_counts_by_option } = usePollState ( ) ;
369+ const ownCapabilities = useOwnCapabilitiesContext ( ) ;
362370 const [ showAllVotes , setShowAllVotes ] = useState ( false ) ;
363371 const { onPress, option } = props ;
364372
@@ -379,7 +387,9 @@ export const ShowAllVotesButton = (props: PollButtonProps & { option: PollOption
379387
380388 return (
381389 < >
382- { vote_counts_by_option && vote_counts_by_option ?. [ option . id ] > 5 ? (
390+ { ownCapabilities . queryPollVotes &&
391+ vote_counts_by_option &&
392+ vote_counts_by_option ?. [ option . id ] > 5 ? (
383393 < GenericPollButton onPress = { onPressHandler } title = { t < string > ( 'Show All' ) } />
384394 ) : null }
385395 { showAllVotes ? (
0 commit comments