aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-27 23:31:20 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-12-28 11:19:57 +0100
commit56c1db077b5da653c230432abc6c746318a77bed (patch)
tree38a984fb6eed2b50bedea02660695ca1a41b3d13 /lib
parent6c9ff40dbd91cc4966f0ecf9ed817efc2495a2fb (diff)
downloadlibquotient-56c1db077b5da653c230432abc6c746318a77bed.tar.gz
libquotient-56c1db077b5da653c230432abc6c746318a77bed.zip
Cleanup and clang-tidy/clazy fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/jobs/basejob.cpp2
-rw-r--r--lib/jobs/basejob.h2
-rw-r--r--lib/room.cpp33
3 files changed, 14 insertions, 23 deletions
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp
index 2ac942f5..1a41f795 100644
--- a/lib/jobs/basejob.cpp
+++ b/lib/jobs/basejob.cpp
@@ -263,7 +263,7 @@ void BaseJob::setExpectedContentTypes(const QByteArrayList& contentTypes)
d->expectedContentTypes = contentTypes;
}
-const QByteArrayList BaseJob::expectedKeys() const { return d->expectedKeys; }
+QByteArrayList BaseJob::expectedKeys() const { return d->expectedKeys; }
void BaseJob::addExpectedKey(const QByteArray& key) { d->expectedKeys << key; }
diff --git a/lib/jobs/basejob.h b/lib/jobs/basejob.h
index a0b89ef7..a72f6120 100644
--- a/lib/jobs/basejob.h
+++ b/lib/jobs/basejob.h
@@ -363,7 +363,7 @@ protected:
const QByteArrayList& expectedContentTypes() const;
void addExpectedContentType(const QByteArray& contentType);
void setExpectedContentTypes(const QByteArrayList& contentTypes);
- const QByteArrayList expectedKeys() const;
+ QByteArrayList expectedKeys() const;
void addExpectedKey(const QByteArray &key);
void setExpectedKeys(const QByteArrayList &keys);
diff --git a/lib/room.cpp b/lib/room.cpp
index a19624d8..602653f3 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -2522,31 +2522,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
}
@@ -2588,7 +2577,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);
}