summary refs log tree commit diff
path: root/src/Community.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-24 20:46:37 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-01-24 20:46:37 +0200
commit1fad9398fce58a8d7bf96bdaa2629a80b336b14c (patch)
tree28483acf18d91d6ccfa40eaa0564e50dd9291c51 /src/Community.cc
parentRemove trailing whitespace from text messages (diff)
downloadnheko-1fad9398fce58a8d7bf96bdaa2629a80b336b14c.tar.xz
Use more stl containers & minor refactorings
Diffstat (limited to 'src/Community.cc')
-rw-r--r--src/Community.cc25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/Community.cc b/src/Community.cc

index a68f2b18..d563c151 100644 --- a/src/Community.cc +++ b/src/Community.cc
@@ -6,29 +6,19 @@ void Community::parseProfile(const QJsonObject &profile) { - if (profile["name"].type() == QJsonValue::Type::String) { + if (profile["name"].type() == QJsonValue::Type::String) name_ = profile["name"].toString(); - } else { + else name_ = "Unnamed Community"; // TODO: what is correct here? - } - if (profile["avatar_url"].type() == QJsonValue::Type::String) { + if (profile["avatar_url"].type() == QJsonValue::Type::String) avatar_ = QUrl(profile["avatar_url"].toString()); - } else { - avatar_ = QUrl(); - } - if (profile["short_description"].type() == QJsonValue::Type::String) { + if (profile["short_description"].type() == QJsonValue::Type::String) short_description_ = profile["short_description"].toString(); - } else { - short_description_ = ""; - } - if (profile["long_description"].type() == QJsonValue::Type::String) { + if (profile["long_description"].type() == QJsonValue::Type::String) long_description_ = profile["long_description"].toString(); - } else { - long_description_ = ""; - } } void @@ -36,7 +26,8 @@ Community::parseRooms(const QJsonObject &rooms) { rooms_.clear(); - for (auto i = 0; i < rooms["chunk"].toArray().size(); i++) { - rooms_.append(rooms["chunk"].toArray()[i].toObject()["room_id"].toString()); + for (auto const &room : rooms["chunk"].toArray()) { + if (room.toObject().contains("room_id")) + rooms_.emplace_back(room.toObject()["room_id"].toString()); } }