Avoid empty membership events

This commit is contained in:
Nicolas Werner 2022-03-28 21:27:42 +02:00
parent 5078bdd14f
commit 6f0260d59f
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -2088,19 +2088,16 @@ TimelineModel::formatMemberEvent(const QString &id)
} }
break; break;
case Membership::Leave: case Membership::Leave:
if (!prevEvent) // Should only ever happen temporarily if (!prevEvent || prevEvent->content.membership == Membership::Join) {
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 (event->state_key == event->sender) if (event->state_key == event->sender)
rendered = tr("%1 left the room.").arg(name); rendered = tr("%1 left the room.").arg(name);
else else
rendered = tr("%2 kicked %1.").arg(name, senderName); 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) { } else if (prevEvent->content.membership == Membership::Ban) {
rendered = tr("%2 unbanned %1.").arg(name, senderName); rendered = tr("%2 unbanned %1.").arg(name, senderName);
} else if (prevEvent->content.membership == Membership::Knock) { } else if (prevEvent->content.membership == Membership::Knock) {