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:
@@ -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" />
|
||||
|
||||
@@ -53,7 +53,7 @@ const mapStateToProps = (state, props) => {
|
||||
|
||||
const activeUnit = state.models.units[props.unitId];
|
||||
return {
|
||||
activeUnitLmsWebUrl: activeUnit.lmsWebUrl,
|
||||
activeUnitLmsWebUrl: activeUnit ? activeUnit.lmsWebUrl : undefined,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user