diff --git a/framework/core/js/admin/dist/app.js b/framework/core/js/admin/dist/app.js index 2d229046d..a7c1137fe 100644 --- a/framework/core/js/admin/dist/app.js +++ b/framework/core/js/admin/dist/app.js @@ -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; - }); + }) : []; } }); diff --git a/framework/core/js/forum/dist/app.js b/framework/core/js/forum/dist/app.js index 54c8b1f89..a47abc535 100644 --- a/framework/core/js/forum/dist/app.js +++ b/framework/core/js/forum/dist/app.js @@ -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; - }); + }) : []; } }); diff --git a/framework/core/js/forum/src/components/DiscussionPage.js b/framework/core/js/forum/src/components/DiscussionPage.js index e67718570..ab7a014c0 100644 --- a/framework/core/js/forum/src/components/DiscussionPage.js +++ b/framework/core/js/forum/src/components/DiscussionPage.js @@ -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); } /** diff --git a/framework/core/js/lib/models/Discussion.js b/framework/core/js/lib/models/Discussion.js index bfecc00d0..d4c6c0ee6 100644 --- a/framework/core/js/lib/models/Discussion.js +++ b/framework/core/js/lib/models/Discussion.js @@ -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) : []; } });