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