aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/users.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/csapi/users.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/csapi/users.cpp')
-rw-r--r--lib/csapi/users.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/csapi/users.cpp b/lib/csapi/users.cpp
index deb9cb8a..97d8962d 100644
--- a/lib/csapi/users.cpp
+++ b/lib/csapi/users.cpp
@@ -16,19 +16,13 @@ namespace QMatrixClient
{
// Converters
- template <> struct FromJsonObject<SearchUserDirectoryJob::User>
+ template <> struct JsonObjectConverter<SearchUserDirectoryJob::User>
{
- SearchUserDirectoryJob::User operator()(const QJsonObject& jo) const
+ static void fillFrom(const QJsonObject& jo, SearchUserDirectoryJob::User& result)
{
- SearchUserDirectoryJob::User result;
- result.userId =
- fromJson<QString>(jo.value("user_id"_ls));
- result.displayName =
- fromJson<QString>(jo.value("display_name"_ls));
- result.avatarUrl =
- fromJson<QString>(jo.value("avatar_url"_ls));
-
- return result;
+ fromJson(jo.value("user_id"_ls), result.userId);
+ fromJson(jo.value("display_name"_ls), result.displayName);
+ fromJson(jo.value("avatar_url"_ls), result.avatarUrl);
}
};
} // namespace QMatrixClient
@@ -71,11 +65,11 @@ BaseJob::Status SearchUserDirectoryJob::parseJson(const QJsonDocument& data)
if (!json.contains("results"_ls))
return { JsonParseError,
"The key 'results' not found in the response" };
- d->results = fromJson<QVector<User>>(json.value("results"_ls));
+ fromJson(json.value("results"_ls), d->results);
if (!json.contains("limited"_ls))
return { JsonParseError,
"The key 'limited' not found in the response" };
- d->limited = fromJson<bool>(json.value("limited"_ls));
+ fromJson(json.value("limited"_ls), d->limited);
return Success;
}