Skip to content

Commit

Permalink
fix: ref to prevent multiple calls
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed May 15, 2024
1 parent 8b77a72 commit 0e313f1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect } from 'react';
import React, { useEffect, useRef } from 'react';
import {
selectPeerNameByID,
selectPermissions,
Expand Down Expand Up @@ -26,11 +26,13 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
const { setPollView } = usePollViewState();
// Sets view - linear or vertical, toggles timer indicator
const showSingleView = poll?.type === 'quiz' && poll.state === 'started';
const fetchedResponses = useRef(false);

useEffect(() => {
const getResponses = async () => {
if (poll && actions.interactivityCenter) {
if (poll && actions.interactivityCenter && !fetchedResponses.current) {
await actions.interactivityCenter.getPollResponses(poll, true);
fetchedResponses.current = true;
}
};
getResponses();
Expand Down

0 comments on commit 0e313f1

Please sign in to comment.