mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Make connections across threads queued in any case
This commit is contained in:
parent
da975038db
commit
f6fa494666
2 changed files with 99 additions and 67 deletions
|
@ -545,8 +545,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
emit notificationsRetrieved(std::move(res));
|
emit notificationsRetrieved(std::move(res));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
connect(this, &ChatPage::syncRoomlist, room_list_, &RoomList::sync);
|
connect(this, &ChatPage::syncRoomlist, room_list_, &RoomList::sync, Qt::QueuedConnection);
|
||||||
connect(this, &ChatPage::syncTags, communitiesList_, &CommunitiesList::syncTags);
|
connect(this,
|
||||||
|
&ChatPage::syncTags,
|
||||||
|
communitiesList_,
|
||||||
|
&CommunitiesList::syncTags,
|
||||||
|
Qt::QueuedConnection);
|
||||||
connect(
|
connect(
|
||||||
this, &ChatPage::syncTopBar, this, [this](const std::map<QString, RoomInfo> &updates) {
|
this, &ChatPage::syncTopBar, this, [this](const std::map<QString, RoomInfo> &updates) {
|
||||||
if (updates.find(currentRoom()) != updates.end())
|
if (updates.find(currentRoom()) != updates.end())
|
||||||
|
@ -561,11 +565,15 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
user_info_widget_->setDisplayName(name);
|
user_info_widget_->setDisplayName(name);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync);
|
connect(
|
||||||
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync);
|
this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection);
|
||||||
connect(this, &ChatPage::tryDelayedSyncCb, this, [this]() {
|
connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection);
|
||||||
QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync);
|
connect(
|
||||||
});
|
this,
|
||||||
|
&ChatPage::tryDelayedSyncCb,
|
||||||
|
this,
|
||||||
|
[this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this, &ChatPage::dropToLoginPageCb, this, &ChatPage::dropToLoginPage);
|
connect(this, &ChatPage::dropToLoginPageCb, this, &ChatPage::dropToLoginPage);
|
||||||
|
|
||||||
|
|
|
@ -144,14 +144,26 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
, room_id_(room_id)
|
, room_id_(room_id)
|
||||||
, manager_(manager)
|
, manager_(manager)
|
||||||
{
|
{
|
||||||
|
connect(this,
|
||||||
|
&TimelineModel::oldMessagesRetrieved,
|
||||||
|
this,
|
||||||
|
&TimelineModel::addBackwardsEvents,
|
||||||
|
Qt::QueuedConnection);
|
||||||
connect(
|
connect(
|
||||||
this, &TimelineModel::oldMessagesRetrieved, this, &TimelineModel::addBackwardsEvents);
|
this,
|
||||||
connect(this, &TimelineModel::messageFailed, this, [this](QString txn_id) {
|
&TimelineModel::messageFailed,
|
||||||
|
this,
|
||||||
|
[this](QString txn_id) {
|
||||||
nhlog::ui()->error("Failed to send {}, retrying", txn_id.toStdString());
|
nhlog::ui()->error("Failed to send {}, retrying", txn_id.toStdString());
|
||||||
|
|
||||||
QTimer::singleShot(5000, this, [this]() { emit nextPendingMessage(); });
|
QTimer::singleShot(5000, this, [this]() { emit nextPendingMessage(); });
|
||||||
});
|
},
|
||||||
connect(this, &TimelineModel::messageSent, this, [this](QString txn_id, QString event_id) {
|
Qt::QueuedConnection);
|
||||||
|
connect(
|
||||||
|
this,
|
||||||
|
&TimelineModel::messageSent,
|
||||||
|
this,
|
||||||
|
[this](QString txn_id, QString event_id) {
|
||||||
pending.removeOne(txn_id);
|
pending.removeOne(txn_id);
|
||||||
|
|
||||||
auto ev = events.value(txn_id);
|
auto ev = events.value(txn_id);
|
||||||
|
@ -191,25 +203,37 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
|
|
||||||
if (pending.size() > 0)
|
if (pending.size() > 0)
|
||||||
emit nextPendingMessage();
|
emit nextPendingMessage();
|
||||||
});
|
},
|
||||||
connect(this, &TimelineModel::redactionFailed, this, [](const QString &msg) {
|
Qt::QueuedConnection);
|
||||||
emit ChatPage::instance()->showNotification(msg);
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
this, &TimelineModel::nextPendingMessage, this, &TimelineModel::processOnePendingMessage);
|
this,
|
||||||
connect(this, &TimelineModel::newMessageToSend, this, &TimelineModel::addPendingMessage);
|
&TimelineModel::redactionFailed,
|
||||||
|
this,
|
||||||
|
[](const QString &msg) { emit ChatPage::instance()->showNotification(msg); },
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this,
|
connect(this,
|
||||||
|
&TimelineModel::nextPendingMessage,
|
||||||
|
this,
|
||||||
|
&TimelineModel::processOnePendingMessage,
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
connect(this,
|
||||||
|
&TimelineModel::newMessageToSend,
|
||||||
|
this,
|
||||||
|
&TimelineModel::addPendingMessage,
|
||||||
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
|
connect(
|
||||||
|
this,
|
||||||
&TimelineModel::eventFetched,
|
&TimelineModel::eventFetched,
|
||||||
this,
|
this,
|
||||||
[this](QString requestingEvent, mtx::events::collections::TimelineEvents event) {
|
[this](QString requestingEvent, mtx::events::collections::TimelineEvents event) {
|
||||||
events.insert(QString::fromStdString(mtx::accessors::event_id(event)),
|
events.insert(QString::fromStdString(mtx::accessors::event_id(event)), event);
|
||||||
event);
|
|
||||||
auto idx = idToIndex(requestingEvent);
|
auto idx = idToIndex(requestingEvent);
|
||||||
if (idx >= 0)
|
if (idx >= 0)
|
||||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||||
});
|
},
|
||||||
|
Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray>
|
QHash<int, QByteArray>
|
||||||
|
|
Loading…
Reference in a new issue