From 6f0260d59f0ae29962933d4345b698916d204e74 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 28 Mar 2022 21:27:42 +0200 Subject: [PATCH] Avoid empty membership events --- src/timeline/TimelineModel.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index 28d8f0bb..3dd51112 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -2088,19 +2088,16 @@ TimelineModel::formatMemberEvent(const QString &id) } break; case Membership::Leave: - if (!prevEvent) // Should only ever happen temporarily - return {}; - - if (prevEvent->content.membership == Membership::Invite) { - if (event->state_key == event->sender) - rendered = tr("%1 rejected their invite.").arg(name); - else - rendered = tr("%2 revoked the invite to %1.").arg(name, senderName); - } else if (prevEvent->content.membership == Membership::Join) { + if (!prevEvent || prevEvent->content.membership == Membership::Join) { if (event->state_key == event->sender) rendered = tr("%1 left the room.").arg(name); else rendered = tr("%2 kicked %1.").arg(name, senderName); + } else if (prevEvent->content.membership == Membership::Invite) { + if (event->state_key == event->sender) + rendered = tr("%1 rejected their invite.").arg(name); + else + rendered = tr("%2 revoked the invite to %1.").arg(name, senderName); } else if (prevEvent->content.membership == Membership::Ban) { rendered = tr("%2 unbanned %1.").arg(name, senderName); } else if (prevEvent->content.membership == Membership::Knock) {