learngerman/patches/0101-fix-broken-exercises.diff

29 lines
1.1 KiB
Diff

--- orig/components/Lesson/LessonExercise/LessonExerciseItem/LessonExerciseItem.jsx 2021-10-11 20:29:07.983390638 -0300
+++ sources-gen/components/Lesson/LessonExercise/LessonExerciseItem/LessonExerciseItem.jsx 2021-10-11 14:15:46.480142077 -0300
@@ -91,12 +91,20 @@
<MediaInputAudio data={data} />
</div>
);
+ // XXX: Here is the problem. These exercises return inputType == 'VIDEO'
+ // even though they don't have any videos (videos == []) causing some
+ // code that assumes that there is a video inside videos to fail
+ // (the MediaInputVideo component.)
case 'VIDEO':
- return (
- <div className="input-header-video">
- <MediaInputVideo data={data} />
- </div>
- );
+ // This "if" is our patch. If it isn't true, it fallsthrough to the default
+ // behaviour (returning null.)
+ if (data.content.videos.length > 0) {
+ return (
+ <div className="input-header-video">
+ <MediaInputVideo data={data} />
+ </div>
+ );
+ }
default:
return null;
}