diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index f2d6b06cdb63dbd2e1ccc93d0c1a5a6573b7d3b3..99739e0879a52769c3dfb25a55f26bc3158c81ec 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -308,11 +308,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) &ChatPage::setGroupViewState); connect(this, &ChatPage::initializeRoomList, room_list_, &RoomList::initialize); - connect(this, - &ChatPage::initializeViews, - view_manager_, - [this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); }, - Qt::QueuedConnection); + connect( + this, + &ChatPage::initializeViews, + view_manager_, + [this](const mtx::responses::Rooms &rooms) { view_manager_->sync(rooms); }, + Qt::QueuedConnection); connect(this, &ChatPage::initializeEmptyViews, view_manager_, @@ -377,11 +378,12 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent) connect( this, &ChatPage::tryInitialSyncCb, this, &ChatPage::tryInitialSync, Qt::QueuedConnection); connect(this, &ChatPage::trySyncCb, this, &ChatPage::trySync, Qt::QueuedConnection); - connect(this, - &ChatPage::tryDelayedSyncCb, - this, - [this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); }, - Qt::QueuedConnection); + connect( + this, + &ChatPage::tryDelayedSyncCb, + this, + [this]() { QTimer::singleShot(RETRY_TIMEOUT, this, &ChatPage::trySync); }, + Qt::QueuedConnection); connect(this, &ChatPage::newSyncResponse, diff --git a/src/CompletionProxyModel.cpp b/src/CompletionProxyModel.cpp index 34625e76d5fd6067f9f9135c31a438a80be15902..44a149114acb0eb112a7b5de7e5f9e07a9ced57e 100644 --- a/src/CompletionProxyModel.cpp +++ b/src/CompletionProxyModel.cpp @@ -45,16 +45,17 @@ CompletionProxyModel::CompletionProxyModel(QAbstractItemModel *model, QObject *p } } - connect(this, - &CompletionProxyModel::newSearchString, - this, - [this](QString s) { - s.remove(":"); - s.remove("@"); - searchString = s.toLower(); - invalidate(); - }, - Qt::QueuedConnection); + connect( + this, + &CompletionProxyModel::newSearchString, + this, + [this](QString s) { + s.remove(":"); + s.remove("@"); + searchString = s.toLower(); + invalidate(); + }, + Qt::QueuedConnection); } void diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp index 410bb091674835439872855792d75868ed1a265f..6104ad0044b8554d21426c0292b0b57609ea493a 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp @@ -39,59 +39,60 @@ EventStore::EventStore(std::string room_id, QObject *) this->last = range->last; } - connect(this, - &EventStore::eventFetched, - this, - [this](std::string id, - std::string relatedTo, - mtx::events::collections::TimelineEvents timeline) { - cache::client()->storeEvent(room_id_, id, {timeline}); - - if (!relatedTo.empty()) { - auto idx = idToIndex(relatedTo); - if (idx) - emit dataChanged(*idx, *idx); - } - }, - Qt::QueuedConnection); - - connect(this, - &EventStore::oldMessagesRetrieved, - this, - [this](const mtx::responses::Messages &res) { - if (cache::client()->previousBatchToken(room_id_) == res.end) { - noMoreMessages = true; - emit fetchedMore(); - return; - } + connect( + this, + &EventStore::eventFetched, + this, + [this](std::string id, + std::string relatedTo, + mtx::events::collections::TimelineEvents timeline) { + cache::client()->storeEvent(room_id_, id, {timeline}); + + if (!relatedTo.empty()) { + auto idx = idToIndex(relatedTo); + if (idx) + emit dataChanged(*idx, *idx); + } + }, + Qt::QueuedConnection); + + connect( + this, + &EventStore::oldMessagesRetrieved, + this, + [this](const mtx::responses::Messages &res) { + if (cache::client()->previousBatchToken(room_id_) == res.end) { + noMoreMessages = true; + emit fetchedMore(); + return; + } - uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res); - if (newFirst == first) - fetchMore(); - else { - if (this->last != std::numeric_limits<uint64_t>::max()) { - emit beginInsertRows(toExternalIdx(newFirst), - toExternalIdx(this->first - 1)); - this->first = newFirst; - emit endInsertRows(); - emit fetchedMore(); - } else { - auto range = cache::client()->getTimelineRange(room_id_); - - if (range && range->last - range->first != 0) { - emit beginInsertRows( - 0, int(range->last - range->first)); - this->first = range->first; - this->last = range->last; - emit endInsertRows(); - emit fetchedMore(); - } else { - fetchMore(); - } - } - } - }, - Qt::QueuedConnection); + uint64_t newFirst = cache::client()->saveOldMessages(room_id_, res); + if (newFirst == first) + fetchMore(); + else { + if (this->last != std::numeric_limits<uint64_t>::max()) { + emit beginInsertRows(toExternalIdx(newFirst), + toExternalIdx(this->first - 1)); + this->first = newFirst; + emit endInsertRows(); + emit fetchedMore(); + } else { + auto range = cache::client()->getTimelineRange(room_id_); + + if (range && range->last - range->first != 0) { + emit beginInsertRows(0, int(range->last - range->first)); + this->first = range->first; + this->last = range->last; + emit endInsertRows(); + emit fetchedMore(); + } else { + fetchMore(); + } + } + } + }, + Qt::QueuedConnection); connect(this, &EventStore::processPending, this, [this]() { if (!current_txn.empty()) { @@ -156,46 +157,48 @@ EventStore::EventStore(std::string room_id, QObject *) event->data); }); - connect(this, - &EventStore::messageFailed, - this, - [this](std::string txn_id) { - if (current_txn == txn_id) { - current_txn_error_count++; - if (current_txn_error_count > 10) { - nhlog::ui()->debug("failing txn id '{}'", txn_id); - cache::client()->removePendingStatus(room_id_, txn_id); - current_txn_error_count = 0; - } - } - QTimer::singleShot(1000, this, [this]() { - nhlog::ui()->debug("timeout"); - this->current_txn = ""; - emit processPending(); - }); - }, - Qt::QueuedConnection); - - connect(this, - &EventStore::messageSent, - this, - [this](std::string txn_id, std::string event_id) { - nhlog::ui()->debug("sent {}", txn_id); - - http::client()->read_event( - room_id_, event_id, [this, event_id](mtx::http::RequestErr err) { - if (err) { - nhlog::net()->warn( - "failed to read_event ({}, {})", room_id_, event_id); - } - }); - - cache::client()->removePendingStatus(room_id_, txn_id); - this->current_txn = ""; - this->current_txn_error_count = 0; - emit processPending(); - }, - Qt::QueuedConnection); + connect( + this, + &EventStore::messageFailed, + this, + [this](std::string txn_id) { + if (current_txn == txn_id) { + current_txn_error_count++; + if (current_txn_error_count > 10) { + nhlog::ui()->debug("failing txn id '{}'", txn_id); + cache::client()->removePendingStatus(room_id_, txn_id); + current_txn_error_count = 0; + } + } + QTimer::singleShot(1000, this, [this]() { + nhlog::ui()->debug("timeout"); + this->current_txn = ""; + emit processPending(); + }); + }, + Qt::QueuedConnection); + + connect( + this, + &EventStore::messageSent, + this, + [this](std::string txn_id, std::string event_id) { + nhlog::ui()->debug("sent {}", txn_id); + + http::client()->read_event( + room_id_, event_id, [this, event_id](mtx::http::RequestErr err) { + if (err) { + nhlog::net()->warn( + "failed to read_event ({}, {})", room_id_, event_id); + } + }); + + cache::client()->removePendingStatus(room_id_, txn_id); + this->current_txn = ""; + this->current_txn_error_count = 0; + emit processPending(); + }, + Qt::QueuedConnection); } void @@ -361,7 +364,7 @@ struct overloaded : Ts... using Ts::operator()...; }; template<class... Ts> -overloaded(Ts...)->overloaded<Ts...>; +overloaded(Ts...) -> overloaded<Ts...>; } void diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index f9a5460ace9b2d7f6c33298083a03c98c7f7a587..7afc75f71ae0ee58395885b266885c9d48617870 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -209,11 +209,12 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj , room_id_(room_id) , manager_(manager) { - connect(this, - &TimelineModel::redactionFailed, - this, - [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, - Qt::QueuedConnection); + connect( + this, + &TimelineModel::redactionFailed, + this, + [](const QString &msg) { emit ChatPage::instance()->showNotification(msg); }, + Qt::QueuedConnection); connect(this, &TimelineModel::newMessageToSend, @@ -222,17 +223,17 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj Qt::QueuedConnection); connect(this, &TimelineModel::addPendingMessageToStore, &events, &EventStore::addPending); - connect(&events, - &EventStore::dataChanged, - this, - [this](int from, int to) { - nhlog::ui()->debug("data changed {} to {}", - events.size() - to - 1, - events.size() - from - 1); - emit dataChanged(index(events.size() - to - 1, 0), - index(events.size() - from - 1, 0)); - }, - Qt::QueuedConnection); + connect( + &events, + &EventStore::dataChanged, + this, + [this](int from, int to) { + nhlog::ui()->debug( + "data changed {} to {}", events.size() - to - 1, events.size() - from - 1); + emit dataChanged(index(events.size() - to - 1, 0), + index(events.size() - from - 1, 0)); + }, + Qt::QueuedConnection); connect(&events, &EventStore::beginInsertRows, this, [this](int from, int to) { int first = events.size() - to; diff --git a/src/ui/SnackBar.cpp b/src/ui/SnackBar.cpp index 2453369d26f1b71e4af91cb5de08acab20172928..2bff903b7362236a4d7162c945b84743b3ee1f92 100644 --- a/src/ui/SnackBar.cpp +++ b/src/ui/SnackBar.cpp @@ -32,9 +32,7 @@ SnackBar::SnackBar(QWidget *parent) offset_anim.setDuration(100); offset_anim.setEasingCurve(QEasingCurve::OutCubic); - connect(this, &SnackBar::offsetChanged, this, [this]() mutable { - repaint(); - }); + connect(this, &SnackBar::offsetChanged, this, [this]() mutable { repaint(); }); connect( &offset_anim, &QPropertyAnimation::finished, this, [this]() { hideTimer_.start(10000); });