Allow loading with no unit, and of sequences with no unitIds. (#34)
This requires some defensive programming here and there to let things load in a minimal state.
This commit is contained in:
@@ -41,14 +41,14 @@ function normalizeBlocks(courseUsageKey, blocks) {
|
||||
models.courses[block.id] = {
|
||||
id: courseUsageKey,
|
||||
title: block.display_name,
|
||||
sectionIds: block.children,
|
||||
sectionIds: block.children || [],
|
||||
};
|
||||
break;
|
||||
case 'chapter':
|
||||
models.sections[block.id] = {
|
||||
id: block.id,
|
||||
title: block.display_name,
|
||||
sequenceIds: block.children,
|
||||
sequenceIds: block.children || [],
|
||||
};
|
||||
break;
|
||||
|
||||
@@ -57,7 +57,7 @@ function normalizeBlocks(courseUsageKey, blocks) {
|
||||
id: block.id,
|
||||
title: block.display_name,
|
||||
lmsWebUrl: block.lms_web_url,
|
||||
unitIds: block.children,
|
||||
unitIds: block.children || [],
|
||||
};
|
||||
break;
|
||||
case 'vertical':
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
getSequenceMetadata,
|
||||
} from './api';
|
||||
import {
|
||||
addModelsMap, updateModel, updateModels,
|
||||
addModelsMap, updateModel, updateModels, updateModelsMap,
|
||||
} from '../model-store';
|
||||
import {
|
||||
fetchCourseRequest,
|
||||
@@ -40,11 +40,12 @@ export function fetchCourse(courseUsageKey) {
|
||||
modelType: 'sections',
|
||||
modelsMap: sections,
|
||||
}));
|
||||
dispatch(addModelsMap({
|
||||
// We update for sequences and units because the sequence metadata may have come back first.
|
||||
dispatch(updateModelsMap({
|
||||
modelType: 'sequences',
|
||||
modelsMap: sequences,
|
||||
}));
|
||||
dispatch(addModelsMap({
|
||||
dispatch(updateModelsMap({
|
||||
modelType: 'units',
|
||||
modelsMap: units,
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user