summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-03-28 21:27:42 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2022-03-28 21:41:16 +0200
commit6f0260d59f0ae29962933d4345b698916d204e74 (patch)
tree5a05cadf6cd548999357615c55682f23d03a19f3
parentdrag to reply (#1018) (diff)
downloadnheko-6f0260d59f0ae29962933d4345b698916d204e74.tar.xz
Avoid empty membership events
-rw-r--r--src/timeline/TimelineModel.cpp15
1 files 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) {