mirror of
https://github.com/flarum/framework.git
synced 2025-02-01 23:09:46 +08:00
Fix crash when displaying a discussion with no posts. closes #823
This commit is contained in:
parent
7b0c318dc9
commit
61a0523e12
6
framework/core/js/admin/dist/app.js
vendored
6
framework/core/js/admin/dist/app.js
vendored
|
@ -22244,9 +22244,11 @@ System.register('flarum/models/Discussion', ['flarum/Model', 'flarum/utils/mixin
|
|||
* @public
|
||||
*/
|
||||
postIds: function postIds() {
|
||||
return this.data.relationships.posts.data.map(function (link) {
|
||||
var posts = this.data.relationships.posts;
|
||||
|
||||
return posts ? posts.data.map(function (link) {
|
||||
return link.id;
|
||||
});
|
||||
}) : [];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
8
framework/core/js/forum/dist/app.js
vendored
8
framework/core/js/forum/dist/app.js
vendored
|
@ -21928,7 +21928,7 @@ System.register('flarum/components/DiscussionPage', ['flarum/components/Page', '
|
|||
// the specific post that was routed to.
|
||||
this.stream = new PostStream({ discussion: discussion, includedPosts: includedPosts });
|
||||
this.stream.on('positionChanged', this.positionChanged.bind(this));
|
||||
this.stream.goToNumber(m.route.param('near') || includedPosts[0].number(), true);
|
||||
this.stream.goToNumber(m.route.param('near') || includedPosts[0] && includedPosts[0].number(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31433,9 +31433,11 @@ System.register('flarum/models/Discussion', ['flarum/Model', 'flarum/utils/mixin
|
|||
* @public
|
||||
*/
|
||||
postIds: function postIds() {
|
||||
return this.data.relationships.posts.data.map(function (link) {
|
||||
var posts = this.data.relationships.posts;
|
||||
|
||||
return posts ? posts.data.map(function (link) {
|
||||
return link.id;
|
||||
});
|
||||
}) : [];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ export default class DiscussionPage extends Page {
|
|||
// the specific post that was routed to.
|
||||
this.stream = new PostStream({discussion, includedPosts});
|
||||
this.stream.on('positionChanged', this.positionChanged.bind(this));
|
||||
this.stream.goToNumber(m.route.param('near') || includedPosts[0].number(), true);
|
||||
this.stream.goToNumber(m.route.param('near') || (includedPosts[0] && includedPosts[0].number()), true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,9 @@ Object.assign(Discussion.prototype, {
|
|||
* @public
|
||||
*/
|
||||
postIds() {
|
||||
return this.data.relationships.posts.data.map(link => link.id);
|
||||
const posts = this.data.relationships.posts;
|
||||
|
||||
return posts ? posts.data.map(link => link.id) : [];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user