diff --git a/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx b/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx
index fcedf91f95..0f43aa4f73 100644
--- a/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx
+++ b/packages/roomkit-react/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx
@@ -1,9 +1,17 @@
// @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 { isNotNullish } from '../../../../Stats/Stats';
import { checkCorrectAnswer } from '../../../common/utils';
import { MultipleChoiceOptions } from '../common/MultipleChoiceOptions';
import { SingleChoiceOptions } from '../common/SingleChoiceOptions';
@@ -23,11 +31,12 @@ export const QuestionCard = ({
answer,
localPeerResponse,
updateSavedResponses,
+ updateUnsavedResponses,
rolesThatCanViewResponses,
}) => {
const actions = useHMSActions();
const localPeer = useHMSStore(selectLocalPeer);
-
+ const roomState = useHMSStore(selectRoomState);
const isLocalPeerCreator = localPeer?.id === startedBy;
const localPeerRoleName = useHMSStore(selectLocalPeerRoleName);
const roleCanViewResponse =
@@ -48,7 +57,6 @@ export const QuestionCard = ({
const canRespond = isLive && !localPeerChoice;
const startTime = useRef(Date.now());
const isCorrectAnswer = checkCorrectAnswer(answer, localPeerChoice, type);
-
const [singleOptionAnswer, setSingleOptionAnswer] = useState();
const [multipleOptionAnswer, setMultipleOptionAnswer] = useState(new Set());
const [showOptions, setShowOptions] = useState(true);
@@ -73,7 +81,15 @@ export const QuestionCard = ({
options: Array.from(multipleOptionAnswer),
duration: Date.now() - startTime.current,
};
- await actions.interactivityCenter.addResponsesToPoll(pollID, [submittedResponse]);
+ if (roomState === HMSRoomState.Connected) {
+ await actions.interactivityCenter.addResponsesToPoll(pollID, [submittedResponse]);
+ } else {
+ updateUnsavedResponses(prev => {
+ const prevCopy = { ...prev };
+ prevCopy[index] = { pollID: pollID, ...submittedResponse };
+ return prevCopy;
+ });
+ }
updateSavedResponses(prev => {
const prevCopy = { ...prev };
prevCopy[index] = { option: singleOptionAnswer, options: Array.from(multipleOptionAnswer) };
@@ -85,9 +101,11 @@ export const QuestionCard = ({
index,
singleOptionAnswer,
multipleOptionAnswer,
+ roomState,
+ updateSavedResponses,
actions.interactivityCenter,
pollID,
- updateSavedResponses,
+ updateUnsavedResponses,
]);
return (
@@ -183,13 +201,21 @@ export const QuestionCard = ({
) : null}
{isLive && (
-
+ 0
+ }
+ isValidVote={isValidVote}
+ onVote={handleVote}
+ response={localPeerChoice}
+ isQuiz={isQuiz}
+ />
)}
);
};
-const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
+const QuestionActions = ({ isValidVote, response, isQuiz, onVote, disableVote }) => {
return (
{response ? (
@@ -199,7 +225,7 @@ const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
{!isQuiz && !response.skipped ? 'Voted' : null}
) : (
-