Fix discussion posts not being initialized correctly. Fixes #1455

This commit is contained in:
Toby Zerner 2018-06-16 11:01:42 +09:30
parent 48e0656601
commit 1a51bbd480

View File

@ -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);