Commit 14f9ffd2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

odrs: Show error messages when remotes misbehave

parent aac7dc47
......@@ -60,6 +60,7 @@ class DISCOVERCOMMON_EXPORT AbstractReviewsBackend : public QObject
Q_SIGNALS:
void reviewsReady(AbstractResource *app, const QVector<ReviewPtr> &reviews, bool canFetchMore);
void loginStateChanged();
void error(const QString &message);
};
#endif // ABSTRACTREVIEWSBACKEND_H
......@@ -145,6 +145,7 @@ void OdrsReviewsBackend::reviewsFetched()
const auto networkError = reply->error();
if (networkError != QNetworkReply::NoError) {
qCWarning(LIBDISCOVER_LOG) << "error fetching reviews:" << reply->errorString() << data;
Q_EMIT error(i18n("Error while fetching reviews: %1", reply->errorString()));
m_isFetching = false;
return;
}
......@@ -190,6 +191,7 @@ void OdrsReviewsBackend::usefulnessSubmitted()
qCWarning(LIBDISCOVER_LOG) << "Usefulness submitted";
} else {
qCWarning(LIBDISCOVER_LOG) << "Failed to submit usefulness: " << reply->errorString();
Q_EMIT error(i18n("Error while submitting usefuless: %1", reply->errorString()));
}
reply->deleteLater();
}
......@@ -238,6 +240,7 @@ void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply)
const QJsonDocument document({resource->getMetadata(QStringLiteral("ODRS::review_map")).toObject()});
parseReviews(document, resource);
} else {
Q_EMIT error(i18n("Error while submitting review: %1", reply->errorString()));
qCWarning(LIBDISCOVER_LOG) << "Failed to submit review: " << reply->errorString();
}
reply->deleteLater();
......
......@@ -109,6 +109,7 @@ FlatpakBackend::FlatpakBackend(QObject* parent)
SourcesModel::global()->addSourcesBackend(m_sources);
}
connect(m_reviews.data(), &OdrsReviewsBackend::error, this, &FlatpakBackend::passiveMessage);
connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, [this] {
m_reviews->emitRatingFetched(this, kTransform<QList<AbstractResource*>>(m_resources.values(), [] (AbstractResource* r) { return r; }));
});
......
......@@ -97,6 +97,7 @@ PackageKitBackend::PackageKitBackend(QObject* parent)
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::restartScheduled, m_updater, &PackageKitUpdater::enableNeedsReboot);
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::isRunningChanged, this, &PackageKitBackend::checkDaemonRunning);
connect(m_reviews.data(), &OdrsReviewsBackend::error, this, &PackageKitBackend::passiveMessage);
connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, [this] {
m_reviews->emitRatingFetched(this, kTransform<QList<AbstractResource*>>(m_packages.packages.values(), [] (AbstractResource* r) { return r; }));
});
......
......@@ -71,6 +71,7 @@ SnapBackend::SnapBackend(QObject* parent)
, m_updater(new StandardBackendUpdater(this))
, m_reviews(AppStreamIntegration::global()->reviews())
{
connect(m_reviews.data(), &OdrsReviewsBackend::error, this, &SnapBackend::passiveMessage);
connect(m_reviews.data(), &OdrsReviewsBackend::ratingsReady, this, [this] {
m_reviews->emitRatingFetched(this, kTransform<QList<AbstractResource*>>(m_resources.values(), [] (AbstractResource* r) { return r; }));
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment