Make main thread more responsive when updating feeds

This commit is contained in:
Bart De Vries 2021-04-11 13:30:21 +02:00
parent ee13a29d10
commit 16c052250c
2 changed files with 4 additions and 2 deletions

View File

@ -132,11 +132,12 @@ void Fetcher::processFeed(Syndication::FeedPtr feed, const QString &url)
query.bindValue(QStringLiteral(":image"), image); query.bindValue(QStringLiteral(":image"), image);
Database::instance().execute(query); Database::instance().execute(query);
qDebug() << "Updated feed title:" << feed->title(); qDebug() << "Updated feed:" << feed->title();
Q_EMIT feedDetailsUpdated(url, feed->title(), image, feed->link(), feed->description(), current); Q_EMIT feedDetailsUpdated(url, feed->title(), image, feed->link(), feed->description(), current);
for (const auto &entry : feed->items()) { for (const auto &entry : feed->items()) {
QCoreApplication::processEvents(); // keep the main thread semi-responsive
processEntry(entry, url, isNewFeed); processEntry(entry, url, isNewFeed);
} }

View File

@ -19,11 +19,12 @@ Kirigami.ScrollablePage {
property var lastFeed: "" property var lastFeed: ""
supportsRefreshing: true supportsRefreshing: true
onRefreshingChanged: onRefreshingChanged: {
if(refreshing) { if(refreshing) {
Fetcher.fetchAll() Fetcher.fetchAll()
refreshing = false refreshing = false
} }
}
contextualActions: [ contextualActions: [
Kirigami.Action { Kirigami.Action {