mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 13:05:50 +08:00
Fix discussion posts not being initialized correctly. Fixes #1455
This commit is contained in:
parent
48e0656601
commit
1a51bbd480
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user