Skip to content

Commit 2eef2a1

Browse files
committed
fix: add support for own capabilities
1 parent 1b32694 commit 2eef2a1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

package/src/components/Poll/components/Button.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ import { PollAllOptions } from './PollOption';
1010

1111
import { 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';
1420
import { Check } from '../../../icons';
1521
import type { DefaultStreamChatGenerics } from '../../../types/types';
1622
import { MessageType } from '../../MessageList/hooks/useMessageList';
@@ -322,6 +328,7 @@ export const ShowAllOptionsButton = (props: PollButtonProps) => {
322328

323329
export 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

Comments
 (0)