Fix 500 out of range bug when completing last challenge

pull/3596/head
Berkeley Martinez 2015-10-05 16:38:58 -07:00
parent 4b05a6edc7
commit 8f84596142
1 changed files with 6 additions and 3 deletions

View File

@ -183,9 +183,9 @@ module.exports = function(app) {
'could not find challenge block for ' + challenge.block
);
}
const nextBlock$ = blocks$.elementAt(blockIndex + 1);
const firstChallengeOfNextBlock$ = nextBlock$
.map(block => block.challenges[0]);
const firstChallengeOfNextBlock$ = blocks$
.elementAtOrDefault(blockIndex + 1, {})
.map(({ challenges = [] }) => challenges[0]);
return blocks$
.elementAt(blockIndex)
@ -214,6 +214,9 @@ module.exports = function(app) {
});
})
.map(nextChallenge => {
if (!nextChallenge) {
return null;
}
nextChallengeName = nextChallenge.dashedName;
return nextChallengeName;
})