Add more tests
This commit is contained in:
parent
62281e1124
commit
5974134ad8
7 changed files with 1418 additions and 231 deletions
|
|
@ -29,6 +29,7 @@ export const useQuizLibrary = (): UseQuizLibraryReturn => {
|
|||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const lastOperationRef = useRef<(() => Promise<void>) | null>(null);
|
||||
const savingRef = useRef(false);
|
||||
|
||||
const fetchQuizzes = useCallback(async () => {
|
||||
if (!isAuthenticated) return;
|
||||
|
|
@ -88,7 +89,7 @@ export const useQuizLibrary = (): UseQuizLibraryReturn => {
|
|||
source: QuizSource,
|
||||
aiTopic?: string
|
||||
): Promise<string> => {
|
||||
if (saving) {
|
||||
if (savingRef.current) {
|
||||
toast.error('Save already in progress');
|
||||
throw new Error('Save already in progress');
|
||||
}
|
||||
|
|
@ -117,6 +118,7 @@ export const useQuizLibrary = (): UseQuizLibraryReturn => {
|
|||
}
|
||||
}
|
||||
|
||||
savingRef.current = true;
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue