diff --git a/src/react/pages/app/QuizInfo.tsx b/src/react/pages/app/QuizInfo.tsx index a703dc2..16ab153 100644 --- a/src/react/pages/app/QuizInfo.tsx +++ b/src/react/pages/app/QuizInfo.tsx @@ -8,9 +8,10 @@ import { useDisclosure } from "@mantine/hooks"; import { Modal } from '@mantine/core'; import { useEffect, useRef, useState, type MutableRefObject } from "react"; import { QRCode } from "react-qrcode-logo" -import { secondDurationToString, type Quiz } from "../../utils"; +import { secondDurationToString, toggleQuiz, type Quiz } from "../../utils"; import { FaLock } from "react-icons/fa"; import { FaLockOpen } from "react-icons/fa"; +import { useQueryClient } from "@tanstack/react-query"; export function QuizInfo() { const [opened, { open, close }] = useDisclosure(false); @@ -75,9 +76,30 @@ const QuizDetails = ({ quiz }: { quiz: Quiz }) => { const createdBy = useUserProfile(quiz.creatorUid) const [showSecrets, setShowSecrets] = useState(false) + const quizzes = useQuizzes(); //Useful only for checking cache state + const [quizToggled, setQuizToggled] = useState(false) + const queryClient = useQueryClient() + + useEffect(() => { + if (quizToggled && !quizzes.isFetching) { + setQuizToggled(false) + } + }, [quizzes.isFetching]) return