Skip to content

Commit

Permalink
Fix bugs caused by not accepting 0 as a valid resource index
Browse files Browse the repository at this point in the history
  • Loading branch information
MisRob committed Oct 19, 2021
1 parent 566c971 commit e383048
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ export default function useLearnerResources() {
if (!lesson) {
return undefined;
}
return lesson.resources.findIndex(r => r.contentnode_id === resource.contentNodeId);
const lessonResourceIdx = lesson.resources.findIndex(
r => r.contentnode_id === resource.contentNodeId
);
return lessonResourceIdx === -1 ? undefined : lessonResourceIdx;
}

/**
Expand Down Expand Up @@ -269,7 +272,7 @@ export default function useLearnerResources() {
*/
function getClassResourceLink(resource) {
const lessonResourceIdx = _getLessonResourceIdx(resource);
if (!lessonResourceIdx) {
if (lessonResourceIdx == undefined) {
return undefined;
}
return {
Expand Down

0 comments on commit e383048

Please sign in to comment.