From 1a51bbd4809c6eb5ecab6d31ad7fb179fb6b1f47 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 16 Jun 2018 11:01:42 +0930 Subject: [PATCH] Fix discussion posts not being initialized correctly. Fixes #1455 --- framework/core/js/forum/src/components/DiscussionPage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/core/js/forum/src/components/DiscussionPage.js b/framework/core/js/forum/src/components/DiscussionPage.js index bc73a8a46..771004b17 100644 --- a/framework/core/js/forum/src/components/DiscussionPage.js +++ b/framework/core/js/forum/src/components/DiscussionPage.js @@ -172,8 +172,13 @@ export default class DiscussionPage extends Page { // the 'discussion' relationship linked, then sorting and splicing. let includedPosts = []; if (discussion.payload && discussion.payload.included) { + const discussionId = discussion.id(); + includedPosts = discussion.payload.included - .filter(record => record.type === 'posts' && record.relationships && record.relationships.discussion) + .filter(record => record.type === 'posts' + && record.relationships + && record.relationships.discussion + && record.relationships.discussion.data.id === discussionId) .map(record => app.store.getById('posts', record.id)) .sort((a, b) => a.id() - b.id()) .slice(0, 20);