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

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