Fix(nav): Protect against missing data

This commit is contained in:
Berkeley Martinez
2016-08-04 15:01:37 -07:00
parent c3c640d00a
commit f0955aea5c
2 changed files with 16 additions and 7 deletions

View File

@ -63,6 +63,10 @@ export function loadCurrentChallengeSaga(actions, getState) {
challengeIdToName[ currentChallengeId ] challengeIdToName[ currentChallengeId ]
]; ];
} }
// challenge data may not be set yet.
if (!finalChallenge.id) {
return Observable.empty();
}
if (finalChallenge.id === currentlyLoadedChallengeId) { if (finalChallenge.id === currentlyLoadedChallengeId) {
// don't reload if the challenge is already loaded. // don't reload if the challenge is already loaded.
// This may change to toast to avoid user confusion // This may change to toast to avoid user confusion

View File

@ -22,12 +22,17 @@ export const firstChallengeSelector = createSelector(
) { ) {
return {}; return {};
} }
return challengeMap[ try {
blockMap[ return challengeMap[
superBlockMap[ blockMap[
superBlocks[0] superBlockMap[
].blocks[0] superBlocks[0]
].challenges[0] ].blocks[0]
]; ].challenges[0]
];
} catch (err) {
console.error(err);
return {};
}
} }
); );