From 053588ae74af91624c769268f3b2271cd1651f18 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 19 Jan 2026 21:10:20 +0100 Subject: [PATCH] Refactor hasExercises computed property in VocabLessonView for improved validation - Enhanced the hasExercises method to include comprehensive checks for lesson and grammarExercises, ensuring robust validation before accessing properties. - Removed redundant computed property declaration to streamline the code structure. - Added additional logging for important vocabulary and grammar explanations to aid in debugging and provide better insights during lesson loading. --- frontend/src/views/social/VocabLessonView.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/social/VocabLessonView.vue b/frontend/src/views/social/VocabLessonView.vue index e8ce0e8..6d846f1 100644 --- a/frontend/src/views/social/VocabLessonView.vue +++ b/frontend/src/views/social/VocabLessonView.vue @@ -264,7 +264,10 @@ export default { computed: { ...mapGetters(['user']), hasExercises() { - return this.lesson && this.lesson.grammarExercises && this.lesson.grammarExercises.length > 0; + if (!this.lesson) return false; + if (!this.lesson.grammarExercises) return false; + if (!Array.isArray(this.lesson.grammarExercises)) return false; + return this.lesson.grammarExercises.length > 0; }, grammarExplanations() { // Extrahiere Grammatik-Erklärungen aus den Übungen @@ -365,9 +368,6 @@ export default { } } }, - computed: { - ...mapGetters(['user']) - }, watch: { courseId() { this.loadLesson(); @@ -390,6 +390,8 @@ export default { console.log('[VocabLessonView] Anzahl Übungen:', this.lesson?.grammarExercises?.length || 0); console.log('[VocabLessonView] activeTab:', this.activeTab); console.log('[VocabLessonView] hasExercises:', this.hasExercises); + console.log('[VocabLessonView] importantVocab:', this.importantVocab); + console.log('[VocabLessonView] grammarExplanations:', this.grammarExplanations); // Initialisiere Übungen aus der Lektion oder lade sie separat if (this.lesson && this.lesson.id) { if (this.lesson.grammarExercises && this.lesson.grammarExercises.length > 0) {