Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/appstream/OdrsReviewsBackend.cpp
Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Line(s) | |||||
240 | void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply) | 240 | void OdrsReviewsBackend::reviewSubmitted(QNetworkReply *reply) | ||
241 | { | 241 | { | ||
242 | #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) | 242 | #if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0)) | ||
243 | const auto networkError = reply->error(); | 243 | const auto networkError = reply->error(); | ||
244 | #else | 244 | #else | ||
245 | const auto networkError = reply->networkError(); | 245 | const auto networkError = reply->networkError(); | ||
246 | #endif | 246 | #endif | ||
247 | if (networkError == QNetworkReply::NoError) { | 247 | if (networkError == QNetworkReply::NoError) { | ||
248 | qCWarning(LIBDISCOVER_LOG) << "Review submitted"; | | |||
249 | AbstractResource *resource = qobject_cast<AbstractResource*>(reply->request().originatingObject()); | 248 | AbstractResource *resource = qobject_cast<AbstractResource*>(reply->request().originatingObject()); | ||
250 | const QJsonArray array = {resource->getMetadata(QStringLiteral("ODRS::review_map")).toObject()}; | 249 | qCWarning(LIBDISCOVER_LOG) << "Review submitted" << resource; | ||
251 | const QJsonDocument document(array); | 250 | const QJsonDocument document({resource->getMetadata(QStringLiteral("ODRS::review_map")).toObject()}); | ||
252 | // Remove local file with reviews so we can re-download it next time to get our review | | |||
253 | QFile file(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/reviews/%1.json").arg(array.first().toObject().value(QStringLiteral("app_id")).toString())); | | |||
254 | file.remove(); | | |||
255 | parseReviews(document, resource); | 251 | parseReviews(document, resource); | ||
256 | } else { | 252 | } else { | ||
257 | qCWarning(LIBDISCOVER_LOG) << "Failed to submit review: " << reply->errorString(); | 253 | qCWarning(LIBDISCOVER_LOG) << "Failed to submit review: " << reply->errorString(); | ||
258 | } | 254 | } | ||
259 | reply->deleteLater(); | 255 | reply->deleteLater(); | ||
260 | } | 256 | } | ||
261 | 257 | | |||
262 | void OdrsReviewsBackend::parseRatings() | 258 | void OdrsReviewsBackend::parseRatings() | ||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |