From e2407e53e3dff937348cbeab39d645fe2c86ad5b Mon Sep 17 00:00:00 2001 From: Abdurrahman Asad <51022010+A-ASAD@users.noreply.github.com> Date: Fri, 22 Apr 2022 21:00:40 +0500 Subject: [PATCH] fix: related to field not shown on posts (#145) --- src/data/thunks.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/data/thunks.js b/src/data/thunks.js index 64b1da97..e2ada391 100644 --- a/src/data/thunks.js +++ b/src/data/thunks.js @@ -58,19 +58,21 @@ function normaliseCourseBlocks({ } else { blocks[verticalId].children?.forEach(discussionId => { const discussion = camelCaseObject(blocks[discussionId]); - const { topicId } = discussion.studentViewData; - blockData[discussionId] = discussion; - // Add this topic id to the list of topics for the current chapter, sequential, and vertical - chapterData.topics.push(topicId); - blockData[sequentialId].topics.push(topicId); - blockData[verticalId].topics.push(topicId); - // Store the topic's context in the course in a map - topics[topicId] = { - chapterName: blockData[chapterId].displayName, - verticalName: blockData[sequentialId].displayName, - unitName: blockData[verticalId].displayName, - unitLink: blockData[verticalId].lmsWebUrl, - }; + const { topicId } = discussion.studentViewData || {}; + if (topicId) { + blockData[discussionId] = discussion; + // Add this topic id to the list of topics for the current chapter, sequential, and vertical + chapterData.topics.push(topicId); + blockData[sequentialId].topics.push(topicId); + blockData[verticalId].topics.push(topicId); + // Store the topic's context in the course in a map + topics[topicId] = { + chapterName: blockData[chapterId].displayName, + verticalName: blockData[sequentialId].displayName, + unitName: blockData[verticalId].displayName, + unitLink: blockData[verticalId].lmsWebUrl, + }; + } }); } });