Implement watchers for courseId and lessonId in VocabLessonView to reset flags on changes
- Added watchers for courseId and lessonId to reset flags related to lesson completion and navigation when either value changes, ensuring proper lesson loading and state management. - Removed redundant method definitions for courseId and lessonId, streamlining the component's code structure and improving maintainability.
This commit is contained in:
@@ -414,6 +414,24 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
courseId(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
// Reset Flags beim Kurswechsel
|
||||
this.isCheckingLessonCompletion = false;
|
||||
this.isNavigatingToNext = false;
|
||||
this.loadLesson();
|
||||
}
|
||||
},
|
||||
lessonId(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
// Reset Flags beim Lektionswechsel
|
||||
this.isCheckingLessonCompletion = false;
|
||||
this.isNavigatingToNext = false;
|
||||
this.loadLesson();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
_extractVocabFromExercises(exercises) {
|
||||
// Sicherstellen, dass exercises ein Array ist
|
||||
@@ -530,24 +548,6 @@ export default {
|
||||
console.log(`[_extractVocabFromExercises] Ergebnis:`, result.length, 'Vokabeln');
|
||||
return result;
|
||||
},
|
||||
courseId(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
// Reset Flags beim Kurswechsel
|
||||
this.isCheckingLessonCompletion = false;
|
||||
this.isNavigatingToNext = false;
|
||||
this.loadLesson();
|
||||
}
|
||||
},
|
||||
lessonId(newVal, oldVal) {
|
||||
if (newVal !== oldVal) {
|
||||
// Reset Flags beim Lektionswechsel
|
||||
this.isCheckingLessonCompletion = false;
|
||||
this.isNavigatingToNext = false;
|
||||
this.loadLesson();
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async loadLesson() {
|
||||
// Verhindere mehrfaches Laden
|
||||
if (this.loading) {
|
||||
|
||||
Reference in New Issue
Block a user