mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
fix linting
This commit is contained in:
parent
a305c2689c
commit
1be42045ee
5 changed files with 131 additions and 126 deletions
|
@ -308,11 +308,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
&ChatPage::setGroupViewState);
|
&ChatPage::setGroupViewState);
|
||||||
|
|
||||||
connect(this, &ChatPage::initializeRoomList, room_list_, &RoomList::initialize);
|
connect(this, &ChatPage::initializeRoomList, room_list_, &RoomList::initialize);
|
||||||
connect(this,
|
connect(
|
||||||
&ChatPage::initializeViews,
|
this,
|
||||||
view_manager_,
|
&ChatPage::initializeViews,
|
||||||
[this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); },
|
view_manager_,
|
||||||
Qt::QueuedConnection);
|
[this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
connect(this,
|
connect(this,
|
||||||
&ChatPage::initializeEmptyViews,
|
&ChatPage::initializeEmptyViews,
|
||||||
view_manager_,
|
view_manager_,
|
||||||
|
@ -377,11 +378,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
connect(
|
connect(
|
||||||
this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection);
|
this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection);
|
||||||
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection);
|
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection);
|
||||||
connect(this,
|
connect(
|
||||||
&ChatPage::tryDelayedSyncCb,
|
this,
|
||||||
this,
|
&ChatPage::tryDelayedSyncCb,
|
||||||
[this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); },
|
this,
|
||||||
Qt::QueuedConnection);
|
[this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this,
|
connect(this,
|
||||||
&ChatPage::newSyncResponse,
|
&ChatPage::newSyncResponse,
|
||||||
|
|
|
@ -45,16 +45,17 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, QObject *p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this,
|
connect(
|
||||||
&CompletionProxyModel::newSearchString,
|
this,
|
||||||
this,
|
&CompletionProxyModel::newSearchString,
|
||||||
[this](QString s) {
|
this,
|
||||||
s.remove(":");
|
[this](QString s) {
|
||||||
s.remove("@");
|
s.remove(":");
|
||||||
searchString = s.toLower();
|
s.remove("@");
|
||||||
invalidate();
|
searchString = s.toLower();
|
||||||
},
|
invalidate();
|
||||||
Qt::QueuedConnection);
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -39,59 +39,60 @@ EventStore::EventStore(std::string room_id, QObject *)
|
||||||
this->last = range->last;
|
this->last = range->last;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this,
|
connect(
|
||||||
&EventStore::eventFetched,
|
this,
|
||||||
this,
|
&EventStore::eventFetched,
|
||||||
[this](std::string id,
|
this,
|
||||||
std::string relatedTo,
|
[this](std::string id,
|
||||||
mtx::events::collections::TimelineEvents timeline) {
|
std::string relatedTo,
|
||||||
cache::client()->storeEvent(room_id_, id, {timeline});
|
mtx::events::collections::TimelineEvents timeline) {
|
||||||
|
cache::client()->storeEvent(room_id_, id, {timeline});
|
||||||
|
|
||||||
if (!relatedTo.empty()) {
|
if (!relatedTo.empty()) {
|
||||||
auto idx = idToIndex(relatedTo);
|
auto idx = idToIndex(relatedTo);
|
||||||
if (idx)
|
if (idx)
|
||||||
emit dataChanged(*idx, *idx);
|
emit dataChanged(*idx, *idx);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this,
|
connect(
|
||||||
&EventStore::oldMessagesRetrieved,
|
this,
|
||||||
this,
|
&EventStore::oldMessagesRetrieved,
|
||||||
[this](const mtx::responses::Messages &res) {
|
this,
|
||||||
if (cache::client()->previousBatchToken(room_id_) == res.end) {
|
[this](const mtx::responses::Messages &res) {
|
||||||
noMoreMessages = true;
|
if (cache::client()->previousBatchToken(room_id_) == res.end) {
|
||||||
emit fetchedMore();
|
noMoreMessages = true;
|
||||||
return;
|
emit fetchedMore();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res);
|
uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res);
|
||||||
if (newFirst == first)
|
if (newFirst == first)
|
||||||
fetchMore();
|
fetchMore();
|
||||||
else {
|
else {
|
||||||
if (this->last != std::numeric_limits<uint64_t>::max()) {
|
if (this->last != std::numeric_limits<uint64_t>::max()) {
|
||||||
emit beginInsertRows(toExternalIdx(newFirst),
|
emit beginInsertRows(toExternalIdx(newFirst),
|
||||||
toExternalIdx(this->first - 1));
|
toExternalIdx(this->first - 1));
|
||||||
this->first = newFirst;
|
this->first = newFirst;
|
||||||
emit endInsertRows();
|
emit endInsertRows();
|
||||||
emit fetchedMore();
|
emit fetchedMore();
|
||||||
} else {
|
} else {
|
||||||
auto range = cache::client()->getTimelineRange(room_id_);
|
auto range = cache::client()->getTimelineRange(room_id_);
|
||||||
|
|
||||||
if (range && range->last - range->first != 0) {
|
if (range && range->last - range->first != 0) {
|
||||||
emit beginInsertRows(
|
emit beginInsertRows(0, int(range->last - range->first));
|
||||||
0, int(range->last - range->first));
|
this->first = range->first;
|
||||||
this->first = range->first;
|
this->last = range->last;
|
||||||
this->last = range->last;
|
emit endInsertRows();
|
||||||
emit endInsertRows();
|
emit fetchedMore();
|
||||||
emit fetchedMore();
|
} else {
|
||||||
} else {
|
fetchMore();
|
||||||
fetchMore();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
Qt::QueuedConnection);
|
||||||
Qt::QueuedConnection);
|
|
||||||
|
|
||||||
connect(this, &EventStore::processPending, this, [this]() {
|
connect(this, &EventStore::processPending, this, [this]() {
|
||||||
if (!current_txn.empty()) {
|
if (!current_txn.empty()) {
|
||||||
|
@ -156,46 +157,48 @@ EventStore::EventStore(std::string room_id, QObject *)
|
||||||
event->data);
|
event->data);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this,
|
connect(
|
||||||
&EventStore::messageFailed,
|
this,
|
||||||
this,
|
&EventStore::messageFailed,
|
||||||
[this](std::string txn_id) {
|
this,
|
||||||
if (current_txn == txn_id) {
|
[this](std::string txn_id) {
|
||||||
current_txn_error_count++;
|
if (current_txn == txn_id) {
|
||||||
if (current_txn_error_count > 10) {
|
current_txn_error_count++;
|
||||||
nhlog::ui()->debug("failing txn id '{}'", txn_id);
|
if (current_txn_error_count > 10) {
|
||||||
cache::client()->removePendingStatus(room_id_, txn_id);
|
nhlog::ui()->debug("failing txn id '{}'", txn_id);
|
||||||
current_txn_error_count = 0;
|
cache::client()->removePendingStatus(room_id_, txn_id);
|
||||||
}
|
current_txn_error_count = 0;
|
||||||
}
|
}
|
||||||
QTimer::singleShot(1000, this, [this]() {
|
}
|
||||||
nhlog::ui()->debug("timeout");
|
QTimer::singleShot(1000, this, [this]() {
|
||||||
this->current_txn = "";
|
nhlog::ui()->debug("timeout");
|
||||||
emit processPending();
|
this->current_txn = "";
|
||||||
});
|
emit processPending();
|
||||||
},
|
});
|
||||||
Qt::QueuedConnection);
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this,
|
connect(
|
||||||
&EventStore::messageSent,
|
this,
|
||||||
this,
|
&EventStore::messageSent,
|
||||||
[this](std::string txn_id, std::string event_id) {
|
this,
|
||||||
nhlog::ui()->debug("sent {}", txn_id);
|
[this](std::string txn_id, std::string event_id) {
|
||||||
|
nhlog::ui()->debug("sent {}", txn_id);
|
||||||
|
|
||||||
http::client()->read_event(
|
http::client()->read_event(
|
||||||
room_id_, event_id, [this, event_id](mtx::http::RequestErr err) {
|
room_id_, event_id, [this, event_id](mtx::http::RequestErr err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
nhlog::net()->warn(
|
nhlog::net()->warn(
|
||||||
"failed to read_event ({}, {})", room_id_, event_id);
|
"failed to read_event ({}, {})", room_id_, event_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
cache::client()->removePendingStatus(room_id_, txn_id);
|
cache::client()->removePendingStatus(room_id_, txn_id);
|
||||||
this->current_txn = "";
|
this->current_txn = "";
|
||||||
this->current_txn_error_count = 0;
|
this->current_txn_error_count = 0;
|
||||||
emit processPending();
|
emit processPending();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -361,7 +364,7 @@ struct overloaded : Ts...
|
||||||
using Ts::operator()...;
|
using Ts::operator()...;
|
||||||
};
|
};
|
||||||
template<class... Ts>
|
template<class... Ts>
|
||||||
overloaded(Ts...)->overloaded<Ts...>;
|
overloaded(Ts...) -> overloaded<Ts...>;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -209,11 +209,12 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
, room_id_(room_id)
|
, room_id_(room_id)
|
||||||
, manager_(manager)
|
, manager_(manager)
|
||||||
{
|
{
|
||||||
connect(this,
|
connect(
|
||||||
&TimelineModel::redactionFailed,
|
this,
|
||||||
this,
|
&TimelineModel::redactionFailed,
|
||||||
[](const QString &msg) { emit ChatPage::instance()->showNotification(msg); },
|
this,
|
||||||
Qt::QueuedConnection);
|
[](const QString &msg) { emit ChatPage::instance()->showNotification(msg); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this,
|
connect(this,
|
||||||
&TimelineModel::newMessageToSend,
|
&TimelineModel::newMessageToSend,
|
||||||
|
@ -222,17 +223,17 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
connect(this, &TimelineModel::addPendingMessageToStore, &events, &EventStore::addPending);
|
connect(this, &TimelineModel::addPendingMessageToStore, &events, &EventStore::addPending);
|
||||||
|
|
||||||
connect(&events,
|
connect(
|
||||||
&EventStore::dataChanged,
|
&events,
|
||||||
this,
|
&EventStore::dataChanged,
|
||||||
[this](int from, int to) {
|
this,
|
||||||
nhlog::ui()->debug("data changed {} to {}",
|
[this](int from, int to) {
|
||||||
events.size() - to - 1,
|
nhlog::ui()->debug(
|
||||||
events.size() - from - 1);
|
"data changed {} to {}", events.size() - to - 1, events.size() - from - 1);
|
||||||
emit dataChanged(index(events.size() - to - 1, 0),
|
emit dataChanged(index(events.size() - to - 1, 0),
|
||||||
index(events.size() - from - 1, 0));
|
index(events.size() - from - 1, 0));
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) {
|
connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) {
|
||||||
int first = events.size() - to;
|
int first = events.size() - to;
|
||||||
|
|
|
@ -32,9 +32,7 @@ SnackBar::SnackBar(QWidget *parent)
|
||||||
offset_anim.setDuration(100);
|
offset_anim.setDuration(100);
|
||||||
offset_anim.setEasingCurve(QEasingCurve::OutCubic);
|
offset_anim.setEasingCurve(QEasingCurve::OutCubic);
|
||||||
|
|
||||||
connect(this, &SnackBar::offsetChanged, this, [this]() mutable {
|
connect(this, &SnackBar::offsetChanged, this, [this]() mutable { repaint(); });
|
||||||
repaint();
|
|
||||||
});
|
|
||||||
connect(
|
connect(
|
||||||
&offset_anim, &QPropertyAnimation::finished, this, [this]() { hideTimer_.start(10000); });
|
&offset_anim, &QPropertyAnimation::finished, this, [this]() { hideTimer_.start(10000); });
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue