Commit fd9cdd9b 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
parent 7f54138e
Pipeline #207246 passed with stage
in 1 minute and 7 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, &ReviewsModel::restartFetching, Qt::QueuedConnection);
}
......
......@@ -110,13 +110,17 @@ void OdrsReviewsBackend::fetchReviews(AbstractResource *app, int page)
return;
}
Q_UNUSED(page)
const QString version = app->isInstalled() ? app->installedVersion() : app->availableVersion();
if (version.isEmpty()) {
return;
}
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