Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update publish-alpha #3410

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// @ts-check
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { match } from 'ts-pattern';
import { selectLocalPeer, selectLocalPeerRoleName, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
import {
HMSRoomState,
selectLocalPeer,
selectLocalPeerRoleName,
selectRoomState,
useHMSActions,
useHMSStore,
} from '@100mslive/react-sdk';
import { CheckCircleIcon, ChevronDownIcon, CrossCircleIcon } from '@100mslive/react-icons';
import { Box, Button, Flex, Text } from '../../../../';
import { checkCorrectAnswer } from '../../../common/utils';
Expand All @@ -27,7 +34,7 @@ export const QuestionCard = ({
}) => {
const actions = useHMSActions();
const localPeer = useHMSStore(selectLocalPeer);

const roomState = useHMSStore(selectRoomState);
const isLocalPeerCreator = localPeer?.id === startedBy;
const localPeerRoleName = useHMSStore(selectLocalPeerRoleName);
const roleCanViewResponse =
Expand Down Expand Up @@ -183,13 +190,19 @@ export const QuestionCard = ({
) : null}
</Box>
{isLive && (
<QuestionActions isValidVote={isValidVote} onVote={handleVote} response={localPeerChoice} isQuiz={isQuiz} />
<QuestionActions
disableVote={roomState !== HMSRoomState.Connected}
isValidVote={isValidVote}
onVote={handleVote}
response={localPeerChoice}
isQuiz={isQuiz}
/>
)}
</Box>
);
};

const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
const QuestionActions = ({ isValidVote, response, isQuiz, onVote, disableVote }) => {
return (
<Flex align="center" justify="end" css={{ gap: '$4', w: '100%' }}>
{response ? (
Expand All @@ -199,7 +212,7 @@ const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
{!isQuiz && !response.skipped ? 'Voted' : null}
</Text>
) : (
<Button css={{ p: '$xs $10', fontWeight: '$semiBold' }} disabled={!isValidVote} onClick={onVote}>
<Button css={{ p: '$xs $10', fontWeight: '$semiBold' }} disabled={!isValidVote || disableVote} onClick={onVote}>
{isQuiz ? 'Answer' : 'Vote'}
</Button>
)}
Expand Down
Loading