aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roommemberevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-12-14 23:32:16 +0900
committerGitHub <noreply@github.com>2018-12-14 23:32:16 +0900
commitfcc8d2ca615fce6e42bf1cf6585d60f94a2db926 (patch)
treeb0dd17b632a5c5775f2221fd0b53b21a8c02ce58 /lib/events/roommemberevent.cpp
parent50571a92b4e9f634c4daf546222fa082120db6c7 (diff)
parent12a0b95fdcfea15cd0ef313aec8868656629b986 (diff)
downloadlibquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.tar.gz
libquotient-fcc8d2ca615fce6e42bf1cf6585d60f94a2db926.zip
Merge pull request #263 from QMatrixClient/kitsune-lazy-loading
Lazy loading members
Diffstat (limited to 'lib/events/roommemberevent.cpp')
-rw-r--r--lib/events/roommemberevent.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/events/roommemberevent.cpp b/lib/events/roommemberevent.cpp
index eaa3302c..a5ac3c5f 100644
--- a/lib/events/roommemberevent.cpp
+++ b/lib/events/roommemberevent.cpp
@@ -23,20 +23,17 @@
#include <array>
-using namespace QMatrixClient;
-
static const std::array<QString, 5> membershipStrings = { {
QStringLiteral("invite"), QStringLiteral("join"),
QStringLiteral("knock"), QStringLiteral("leave"),
QStringLiteral("ban")
} };
-namespace QMatrixClient
-{
+namespace QMatrixClient {
template <>
- struct FromJson<MembershipType>
+ struct JsonConverter<MembershipType>
{
- MembershipType operator()(const QJsonValue& jv) const
+ static MembershipType load(const QJsonValue& jv)
{
const auto& membershipString = jv.toString();
for (auto it = membershipStrings.begin();
@@ -48,9 +45,10 @@ namespace QMatrixClient
return MembershipType::Undefined;
}
};
-
}
+using namespace QMatrixClient;
+
MemberEventContent::MemberEventContent(const QJsonObject& json)
: membership(fromJson<MembershipType>(json["membership"_ls]))
, isDirect(json["is_direct"_ls].toBool())