From 57ca2948eb804f25d30a6709a491cf11798f8e5a Mon Sep 17 00:00:00 2001 From: David Joy Date: Mon, 23 Mar 2020 11:59:34 -0400 Subject: [PATCH] fix: unit object not always ready when course loaded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we don’t yet have the course blocks API loaded when the course metadata finishes, `unit` will be undefined still, and `unit.id` will fail. --- src/courseware/course/Course.jsx | 3 +-- src/courseware/course/InstructorToolbar.jsx | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/courseware/course/Course.jsx b/src/courseware/course/Course.jsx index 55aceb17..bd396290 100644 --- a/src/courseware/course/Course.jsx +++ b/src/courseware/course/Course.jsx @@ -32,7 +32,6 @@ function Course({ const course = useModel('courses', courseId); const sequence = useModel('sequences', sequenceId); const section = useModel('sections', sequence ? sequence.sectionId : null); - const unit = useModel('units', unitId); useLogistrationAlert(); useEnrollmentAlert(courseId); @@ -60,7 +59,7 @@ function Course({ /> {isStaff && ( )} diff --git a/src/courseware/course/InstructorToolbar.jsx b/src/courseware/course/InstructorToolbar.jsx index e18dd739..7b3ddb84 100644 --- a/src/courseware/course/InstructorToolbar.jsx +++ b/src/courseware/course/InstructorToolbar.jsx @@ -53,7 +53,7 @@ const mapStateToProps = (state, props) => { const activeUnit = state.models.units[props.unitId]; return { - activeUnitLmsWebUrl: activeUnit.lmsWebUrl, + activeUnitLmsWebUrl: activeUnit ? activeUnit.lmsWebUrl : undefined, }; };