From 6c6c56613d0ee6bbaf064f89ca2e1d60f5971b80 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Mon, 13 Jul 2020 18:51:43 +0300 Subject: [PATCH] FIX: Check if last poster exists before using it There was a problem when admins viewed topics where the last poster was deleted. --- .../javascripts/discourse/app/lib/transform-post.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/lib/transform-post.js b/app/assets/javascripts/discourse/app/lib/transform-post.js index a083d8fe07b..19ec24ddbc7 100644 --- a/app/assets/javascripts/discourse/app/lib/transform-post.js +++ b/app/assets/javascripts/discourse/app/lib/transform-post.js @@ -172,9 +172,11 @@ export default function transformPost( postAtts.createdByName = createdBy.name; postAtts.lastPostUrl = topic.get("lastPostUrl"); - postAtts.lastPostUsername = details.last_poster.username; - postAtts.lastPostAvatarTemplate = details.last_poster.avatar_template; - postAtts.lastPostName = details.last_poster.name; + if (details.last_poster) { + postAtts.lastPostUsername = details.last_poster.username; + postAtts.lastPostAvatarTemplate = details.last_poster.avatar_template; + postAtts.lastPostName = details.last_poster.name; + } postAtts.lastPostAt = topic.last_posted_at; postAtts.topicReplyCount = topic.get("replyCount");