aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-28 11:24:59 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-28 11:24:59 +0100
commit6ee20f1507b12fcb9556717eeb2784c7530ec588 (patch)
tree6e3bfb6c0167bbb384257e9e5069df57e1ebacb1 /lib
parent12c37cf3ce2aa397050fff6ce846d557524a3fe7 (diff)
downloadlibquotient-6ee20f1507b12fcb9556717eeb2784c7530ec588.tar.gz
libquotient-6ee20f1507b12fcb9556717eeb2784c7530ec588.zip
Cleanup and clang-tidy/clazy fixes
(cherry picked from commit 56c1db077b5da653c230432abc6c746318a77bed)
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 9c932ed6..c42e618e 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -2492,31 +2492,20 @@ Room::Changes Room::processStateEvent(const RoomEvent& e)
, [this, oldStateEvent] (const RoomCanonicalAliasEvent& cae) {
// clang-format on
setObjectName(cae.alias().isEmpty() ? d->id : cae.alias());
- QString previousCanonicalAlias =
- oldStateEvent
- ? static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent)
- ->alias()
- : QString();
-
- auto previousAltAliases =
- oldStateEvent
- ? static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent)
- ->altAliases()
- : QStringList();
-
- if (!previousCanonicalAlias.isEmpty()) {
- previousAltAliases.push_back(previousCanonicalAlias);
+ const auto* oldCae =
+ static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent);
+ QStringList previousAltAliases {};
+ if (oldCae) {
+ previousAltAliases = oldCae->altAliases();
+ if (!oldCae->alias().isEmpty())
+ previousAltAliases.push_back(oldCae->alias());
}
- const auto previousAliases = std::move(previousAltAliases);
-
auto newAliases = cae.altAliases();
-
- if (!cae.alias().isEmpty()) {
+ if (!cae.alias().isEmpty())
newAliases.push_front(cae.alias());
- }
- connection()->updateRoomAliases(id(), previousAliases, newAliases);
+ connection()->updateRoomAliases(id(), previousAltAliases, newAliases);
return AliasesChange;
// clang-format off
}
@@ -2552,7 +2541,9 @@ Room::Changes Room::processStateEvent(const RoomEvent& e)
if (u == localUser() && evt.isDirect())
connection()->addToDirectChats(this, user(evt.senderId()));
break;
- default:
+ case MembershipType::Knock:
+ case MembershipType::Ban:
+ case MembershipType::Leave:
if (!d->membersLeft.contains(u))
d->membersLeft.append(u);
}