diff --git a/src/RoomMessages.cc b/src/RoomMessages.cc
deleted file mode 100644
index 8f6ba450..00000000
--- a/src/RoomMessages.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "RoomMessages.h"
-
-void
-RoomMessages::deserialize(const QJsonDocument &data)
-{
- if (!data.isObject())
- throw DeserializationException("response is not a JSON object");
-
- QJsonObject object = data.object();
-
- if (!object.contains("start"))
- throw DeserializationException("start key is missing");
-
- if (!object.contains("end"))
- throw DeserializationException("end key is missing");
-
- if (!object.contains("chunk"))
- throw DeserializationException("chunk key is missing");
-
- if (!object.value("chunk").isArray())
- throw DeserializationException("chunk isn't a JSON array");
-
- start_ = object.value("start").toString();
- end_ = object.value("end").toString();
- chunk_ = object.value("chunk").toArray();
-}
diff --git a/src/RoomState.cc b/src/RoomState.cc
index afd887ad..244d9e51 100644
--- a/src/RoomState.cc
+++ b/src/RoomState.cc
@@ -22,7 +22,6 @@
#include "RoomState.h"
-RoomState::RoomState() {}
RoomState::RoomState(const mtx::responses::Timeline &timeline)
{
updateFromEvents(timeline.events);
diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc
index 999d608c..33da7f82 100644
--- a/src/timeline/TimelineView.cc
+++ b/src/timeline/TimelineView.cc
@@ -21,7 +21,6 @@
#include "Config.h"
#include "FloatingButton.h"
-#include "RoomMessages.h"
#include "Utils.h"
#include "timeline/TimelineView.h"
@@ -578,17 +577,12 @@ TimelineView::isPendingMessage(const QString &txnid,
if (sender != local_userid)
return false;
- for (const auto &msg : pending_msgs_) {
- if (QString::number(msg.txn_id) == txnid)
- return true;
- }
-
- for (const auto &msg : pending_sent_msgs_) {
- if (QString::number(msg.txn_id) == txnid)
- return true;
- }
+ auto match_txnid = [txnid](const auto &msg) -> bool {
+ return QString::number(msg.txn_id) == txnid;
+ };
- return false;
+ return std::any_of(pending_msgs_.cbegin(), pending_msgs_.cend(), match_txnid) ||
+ std::any_of(pending_sent_msgs_.cbegin(), pending_sent_msgs_.cend(), match_txnid);
}
void
diff --git a/src/timeline/TimelineViewManager.cc b/src/timeline/TimelineViewManager.cc
index 3fee59c7..ccbf509b 100644
--- a/src/timeline/TimelineViewManager.cc
+++ b/src/timeline/TimelineViewManager.cc
@@ -206,8 +206,8 @@ TimelineViewManager::addRoom(const QString &room_id)
void
TimelineViewManager::sync(const mtx::responses::Rooms &rooms)
{
- for (auto it = rooms.join.cbegin(); it != rooms.join.cend(); ++it) {
- auto roomid = QString::fromStdString(it->first);
+ for (const auto &room : rooms.join) {
+ auto roomid = QString::fromStdString(room.first);
if (!timelineViewExists(roomid)) {
qDebug() << "Ignoring event from unknown room" << roomid;
@@ -216,7 +216,7 @@ TimelineViewManager::sync(const mtx::responses::Rooms &rooms)
auto view = views_.at(roomid);
- view->addEvents(it->second.timeline);
+ view->addEvents(room.second.timeline);
}
}
@@ -309,9 +309,7 @@ TimelineViewManager::displayName(const QString &userid)
bool
TimelineViewManager::hasLoaded() const
{
- for (const auto &view : views_)
- if (!view.second->hasLoaded())
- return false;
-
- return true;
+ return std::all_of(views_.cbegin(), views_.cend(), [](const auto &view) {
+ return view.second->hasLoaded();
+ });
}
|