diff --git a/frontend/src/pages/GenerateIt.tsx b/frontend/src/pages/GenerateIt.tsx index 7bd3b7f..b6c259c 100644 --- a/frontend/src/pages/GenerateIt.tsx +++ b/frontend/src/pages/GenerateIt.tsx @@ -180,11 +180,15 @@ export default function GenerateIt() { getObjectWords(selectedObjId, token).then(setObjWords).catch(console.error) }, [selectedObjId, token]) - const reloadQW = (objId: string) => { + const reloadQW = async (objId: string) => { if (!token) return - purgeOrphans(objId, token).catch(console.error) - getObjectQuestions(objId, token).then(setQuestions).catch(console.error) - getObjectWords(objId, token).then(setObjWords).catch(console.error) + await purgeOrphans(objId, token).catch(console.error) + const [qs, ws] = await Promise.all([ + getObjectQuestions(objId, token).catch(() => [] as ObjectQuestion[]), + getObjectWords(objId, token).catch(() => [] as ObjectWord[]), + ]) + setQuestions(qs) + setObjWords(ws) } const handleDeleteQuestion = async (qId: string) => { @@ -348,6 +352,7 @@ export default function GenerateIt() { try { const r = await purgeAllOrphans(token) alert(`Bereinigt: ${r.orphans_removed} verwaiste Einträge entfernt`) + if (selectedObjId) await reloadQW(selectedObjId) } catch (e: unknown) { alert(`Fehler: ${e instanceof Error ? e.message : e}`) }