From 18f3a816ed3149bd336a5b7782773a582cc5314d Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 13 Aug 2019 14:33:16 +0200 Subject: [PATCH] re-enabled loading recent messages concurrently @pajlada please check if the code can stay commented out --- src/common/NetworkRequest.cpp | 37 +++++++++++++------------- src/messages/Image.cpp | 2 +- src/providers/twitch/TwitchChannel.cpp | 10 +++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/common/NetworkRequest.cpp b/src/common/NetworkRequest.cpp index e813794c7..dca08fa82 100644 --- a/src/common/NetworkRequest.cpp +++ b/src/common/NetworkRequest.cpp @@ -301,26 +301,27 @@ void NetworkRequest::doRequest() reply->deleteLater(); }; - if (data->caller_ != nullptr) - { - QObject::connect(worker, &NetworkWorker::doneUrl, data->caller_, - handleReply); - QObject::connect(reply, &QNetworkReply::finished, worker, - [worker]() mutable { - emit worker->doneUrl(); + // FOURTF: Not sure what this does but it doesn't work. + // if (data->caller_ != nullptr) + // { + // QObject::connect(worker, &NetworkWorker::doneUrl, data->caller_, + // handleReply); + // QObject::connect(reply, &QNetworkReply::finished, worker, + // [worker]() mutable { + // emit worker->doneUrl(); - delete worker; - }); - } - else - { - QObject::connect(reply, &QNetworkReply::finished, worker, - [handleReply, worker]() mutable { - handleReply(); + // delete worker; + // }); + // } + // else + // { + QObject::connect(reply, &QNetworkReply::finished, worker, + [handleReply, worker]() mutable { + handleReply(); - delete worker; - }); - } + delete worker; + }); + // } }; QObject::connect(&requester, &NetworkRequester::requestUrl, worker, diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 2bf4b68f1..a8ea7da17 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -213,7 +213,7 @@ ImagePtr Image::fromUrl(const Url &url, qreal scale) } else { - qDebug() << "same image loaded multiple times:" << url.string; + // qDebug() << "same image created multiple times:" << url.string; } return shared; diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index f2eba6f40..5ec10aa3a 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -612,7 +612,7 @@ void TwitchChannel::loadRecentMessages() Env::get().recentMessagesApiUrl.arg(this->getName())); request.setCaller(QThread::currentThread()); // can't be concurrent right now due to SignalVector - // request.setExecuteConcurrently(true); + request.setExecuteConcurrently(true); request.onSuccess([weak = weakOf(this)](auto result) -> Outcome { auto shared = weak.lock(); @@ -635,10 +635,10 @@ void TwitchChannel::loadRecentMessages() } } - // postToThread( - // [shared, messages = std::move(allBuiltMessages)]() mutable { - shared->addMessagesAtStart(allBuiltMessages); - // }); + postToThread( + [shared, messages = std::move(allBuiltMessages)]() mutable { + shared->addMessagesAtStart(messages); + }); return Success; });