mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Remove dead code & small refactorings using the std library
This commit is contained in:
parent
564d51943e
commit
7f7f3a805b
7 changed files with 12 additions and 103 deletions
|
@ -196,7 +196,6 @@ set(SRC_FILES
|
||||||
src/RegisterPage.cc
|
src/RegisterPage.cc
|
||||||
src/RoomInfoListItem.cc
|
src/RoomInfoListItem.cc
|
||||||
src/RoomList.cc
|
src/RoomList.cc
|
||||||
src/RoomMessages.cc
|
|
||||||
src/RoomState.cc
|
src/RoomState.cc
|
||||||
src/RunGuard.cc
|
src/RunGuard.cc
|
||||||
src/SideBarActions.cc
|
src/SideBarActions.cc
|
||||||
|
|
|
@ -1,38 +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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QJsonArray>
|
|
||||||
#include <QJsonDocument>
|
|
||||||
|
|
||||||
#include "Deserializable.h"
|
|
||||||
|
|
||||||
class RoomMessages : public Deserializable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void deserialize(const QJsonDocument &data) override;
|
|
||||||
|
|
||||||
QString start() const { return start_; };
|
|
||||||
QString end() const { return end_; };
|
|
||||||
QJsonArray chunk() const { return chunk_; };
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString start_;
|
|
||||||
QString end_;
|
|
||||||
QJsonArray chunk_;
|
|
||||||
};
|
|
|
@ -26,7 +26,7 @@
|
||||||
class RoomState
|
class RoomState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RoomState();
|
RoomState() = default;
|
||||||
RoomState(const mtx::responses::Timeline &timeline);
|
RoomState(const mtx::responses::Timeline &timeline);
|
||||||
RoomState(const mtx::responses::State &state);
|
RoomState(const mtx::responses::State &state);
|
||||||
|
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "RoomState.h"
|
#include "RoomState.h"
|
||||||
|
|
||||||
RoomState::RoomState() {}
|
|
||||||
RoomState::RoomState(const mtx::responses::Timeline &timeline)
|
RoomState::RoomState(const mtx::responses::Timeline &timeline)
|
||||||
{
|
{
|
||||||
updateFromEvents(timeline.events);
|
updateFromEvents(timeline.events);
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "FloatingButton.h"
|
#include "FloatingButton.h"
|
||||||
#include "RoomMessages.h"
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "timeline/TimelineView.h"
|
#include "timeline/TimelineView.h"
|
||||||
|
@ -578,17 +577,12 @@ TimelineView::isPendingMessage(const QString &txnid,
|
||||||
if (sender != local_userid)
|
if (sender != local_userid)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (const auto &msg : pending_msgs_) {
|
auto match_txnid = [txnid](const auto &msg) -> bool {
|
||||||
if (QString::number(msg.txn_id) == txnid)
|
return QString::number(msg.txn_id) == txnid;
|
||||||
return true;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &msg : pending_sent_msgs_) {
|
return std::any_of(pending_msgs_.cbegin(), pending_msgs_.cend(), match_txnid) ||
|
||||||
if (QString::number(msg.txn_id) == txnid)
|
std::any_of(pending_sent_msgs_.cbegin(), pending_sent_msgs_.cend(), match_txnid);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -206,8 +206,8 @@ TimelineViewManager::addRoom(const QString &room_id)
|
||||||
void
|
void
|
||||||
TimelineViewManager::sync(const mtx::responses::Rooms &rooms)
|
TimelineViewManager::sync(const mtx::responses::Rooms &rooms)
|
||||||
{
|
{
|
||||||
for (auto it = rooms.join.cbegin(); it != rooms.join.cend(); ++it) {
|
for (const auto &room : rooms.join) {
|
||||||
auto roomid = QString::fromStdString(it->first);
|
auto roomid = QString::fromStdString(room.first);
|
||||||
|
|
||||||
if (!timelineViewExists(roomid)) {
|
if (!timelineViewExists(roomid)) {
|
||||||
qDebug() << "Ignoring event from unknown room" << roomid;
|
qDebug() << "Ignoring event from unknown room" << roomid;
|
||||||
|
@ -216,7 +216,7 @@ TimelineViewManager::sync(const mtx::responses::Rooms &rooms)
|
||||||
|
|
||||||
auto view = views_.at(roomid);
|
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
|
bool
|
||||||
TimelineViewManager::hasLoaded() const
|
TimelineViewManager::hasLoaded() const
|
||||||
{
|
{
|
||||||
for (const auto &view : views_)
|
return std::all_of(views_.cbegin(), views_.cend(), [](const auto &view) {
|
||||||
if (!view.second->hasLoaded())
|
return view.second->hasLoaded();
|
||||||
return false;
|
});
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue