From 66fadd78a30d620782783f42cca095ba3287daca Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Mon, 31 Oct 2022 16:18:23 +0100 Subject: [PATCH] Improve messages for bans without given reason --- src/neochatroom.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index 87e32e473..f28bf0232 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -553,8 +553,15 @@ QString NeoChatRoom::eventToString(const RoomEvent &evt, Qt::TextFormat format, ? i18n("has put %1 out of the room: %2", subjectName, e.contentJson()["reason"_ls].toString().toHtmlEscaped()) : i18n("left the room"); case MembershipType::Ban: - return (e.senderId() != e.userId()) ? i18n("banned %1 from the room: %2", subjectName, e.contentJson()["reason"_ls].toString().toHtmlEscaped()) - : i18n("self-banned from the room"); + if (e.senderId() != e.userId()) { + if (e.reason().isEmpty()) { + return i18n("banned %1 from the room", subjectName); + } else { + return i18n("banned %1 from the room: %2", subjectName, e.reason().toHtmlEscaped()); + } + } else { + return i18n("self-banned from the room"); + } case MembershipType::Knock: return i18n("requested an invite"); default:;