fix: unit object not always ready when course loaded

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.
This commit is contained in:
David Joy
2020-03-23 11:59:34 -04:00
parent 9cbb765f8a
commit 57ca2948eb
2 changed files with 2 additions and 3 deletions

View File

@@ -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 && (
<InstructorToolbar
unitId={unit.id}
unitId={unitId}
/>
)}
<CourseTabsNavigation tabs={tabs} activeTabSlug="courseware" />

View File

@@ -53,7 +53,7 @@ const mapStateToProps = (state, props) => {
const activeUnit = state.models.units[props.unitId];
return {
activeUnitLmsWebUrl: activeUnit.lmsWebUrl,
activeUnitLmsWebUrl: activeUnit ? activeUnit.lmsWebUrl : undefined,
};
};