From 853076fd5eacfb6dc4c9dc23ba6192da63915215 Mon Sep 17 00:00:00 2001 From: Gisle Aune Date: Sun, 17 Mar 2019 21:44:07 +0100 Subject: [PATCH] Fixed story chapters being unresponsive if there are no comments. --- .../components/create-comment-modal/component.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/marko/page/story-content/components/create-comment-modal/component.js b/marko/page/story-content/components/create-comment-modal/component.js index 3617ce1..4c7c1cd 100644 --- a/marko/page/story-content/components/create-comment-modal/component.js +++ b/marko/page/story-content/components/create-comment-modal/component.js @@ -30,9 +30,11 @@ module.exports = class { const comments = this.input.chapter.comments || [] const lastComment = comments[comments.length - 1] - let date = lastComment.fictionalDate || chapter.fictionalDate - if (date != null) { - this.change("fictionalDate", {target: {value: moment(date).format("MMM D, YYYY")}}) + if (lastComment != null) { + let date = lastComment.fictionalDate || this.input.chapter.fictionalDate + if (date != null) { + this.change("fictionalDate", {target: {value: moment(date).format("MMM D, YYYY")}}) + } } }