Commit 55ee333e authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

odrs: Make sure we don't fail when the application page is opened early

If it's too early, on the packagekit backend the version won't be
populated yet. In this case we just skip fetching and refetch when the
versions change.

BUG: 426270

(cherry picked from commit fd9cdd9b)
parent 9f06c84d
Pipeline #207247 passed with stage
in 1 minute and 5 seconds
......@@ -92,11 +92,13 @@ void ReviewsModel::setResource(AbstractResource *app)
if (m_backend) {
disconnect(m_backend, &AbstractReviewsBackend::reviewsReady, this, &ReviewsModel::addReviews);
disconnect(m_app, &AbstractResource::versionsChanged, this, &ReviewsModel::restartFetching);
m_app = app;
m_backend = app ? app->backend()->reviewsBackend() : nullptr;
if (m_backend) {
connect(m_backend, &AbstractReviewsBackend::reviewsReady, this, &ReviewsModel::addReviews);
connect(m_app, &AbstractResource::versionsChanged, this, &ReviewsModel::restartFetching);
QMetaObject::invokeMethod(this, "restartFetching", Qt::QueuedConnection);
......@@ -110,13 +110,17 @@ void OdrsReviewsBackend::fetchReviews(AbstractResource *app, int page)
const QString version = app->isInstalled() ? app->installedVersion() : app->availableVersion();
if (version.isEmpty()) {
m_isFetching = true;
const QJsonDocument document(QJsonObject{
{QStringLiteral("app_id"), app->appstreamId()},
{QStringLiteral("distro"), osName()},
{QStringLiteral("user_hash"), userHash()},
{QStringLiteral("version"), app->isInstalled() ? app->installedVersion() : app->availableVersion()},
{QStringLiteral("version"), version},
{QStringLiteral("locale"), QLocale::system().name()},
{QStringLiteral("limit"), -1},
Supports Markdown
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