feat: verbessere Fehlerbehandlung und optimiere das Laden von Vokabeln im VocabPracticeDialog
All checks were successful
Deploy to production / deploy (push) Successful in 2m5s

This commit is contained in:
Torsten Schulz (local)
2026-06-03 16:50:28 +02:00
parent 8b0aa94715
commit b5582045a9

View File

@@ -765,17 +765,18 @@ export default {
}
this.loading = true;
try {
let res;
let res = null;
let courseDueRes = null;
// Wenn SRS-Modus auf Kurs-Ebene, lade kursweite fällige Items (Server liefert totalDueCount)
if (this.srsMode && this.openParams.courseId && !this.openParams.lessonId) {
try {
courseDueRes = await apiClient.get(`/api/vocab/courses/${this.openParams.courseId}/srs/due`, { params: { limit: 100 } });
} catch (e) {
// ignore, fallback to lesson/chapters/vocabs endpoints
} catch (err) {
courseDueRes = null;
}
}
if (courseDueRes && Array.isArray(courseDueRes.data?.items) && courseDueRes.data.items.length > 0) {
// Map server items to pool shape (use itemKey as id)
this.pool = this.normalizePool((courseDueRes.data.items || []).map((it) => ({
@@ -786,12 +787,11 @@ export default {
})));
this.srsServerTotalDue = Number.isFinite(Number(courseDueRes.data?.totalDueCount)) ? Number(courseDueRes.data.totalDueCount) : null;
} else {
// Fallback: lade Lehr- bzw. Kapitel-/Kurs-Vokabeln
if (this.openParams.lessonId) {
if (this.allVocabs && this.openParams.courseId) {
res = await apiClient.get(`/api/vocab/courses/${this.openParams.courseId}/completed-lesson-vocabs`, {
params: {
untilLessonId: this.openParams.lessonId
}
params: { untilLessonId: this.openParams.lessonId }
});
this.pool = this.normalizePool(res.data?.vocabs || []);
} else {
@@ -805,6 +805,7 @@ export default {
res = await apiClient.get(`/api/vocab/chapters/${this.openParams.chapterId}/vocabs`);
this.pool = this.normalizePool(res.data?.vocabs || []);
}
}
} catch (e) {
console.error('Reload pool failed:', e);
this.pool = [];