feat: verbessere Fehlerbehandlung und optimiere das Laden von Vokabeln im VocabPracticeDialog
All checks were successful
Deploy to production / deploy (push) Successful in 2m5s
All checks were successful
Deploy to production / deploy (push) Successful in 2m5s
This commit is contained in:
@@ -763,48 +763,49 @@ export default {
|
||||
this.next();
|
||||
return;
|
||||
}
|
||||
this.loading = true;
|
||||
this.loading = true;
|
||||
try {
|
||||
let res;
|
||||
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
|
||||
courseDueRes = null;
|
||||
}
|
||||
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 (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) => ({
|
||||
id: it.itemKey,
|
||||
learning: it.learning,
|
||||
reference: it.reference,
|
||||
lessonId: it.lessonId || null
|
||||
})));
|
||||
this.srsServerTotalDue = Number.isFinite(Number(courseDueRes.data?.totalDueCount)) ? Number(courseDueRes.data.totalDueCount) : null;
|
||||
} else {
|
||||
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 || []);
|
||||
}
|
||||
|
||||
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) => ({
|
||||
id: it.itemKey,
|
||||
learning: it.learning,
|
||||
reference: it.reference,
|
||||
lessonId: it.lessonId || null
|
||||
})));
|
||||
this.srsServerTotalDue = Number.isFinite(Number(courseDueRes.data?.totalDueCount)) ? Number(courseDueRes.data.totalDueCount) : null;
|
||||
} else {
|
||||
res = await apiClient.get(`/api/vocab/chapters/${this.openParams.chapterId}/vocabs`);
|
||||
this.pool = this.normalizePool(res.data?.vocabs || []);
|
||||
// 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 }
|
||||
});
|
||||
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) {
|
||||
console.error('Reload pool failed:', e);
|
||||
this.pool = [];
|
||||
|
||||
Reference in New Issue
Block a user