Merge lp:~dobey/unity-scope-click/missing-reviews into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: Charles Kerr
Approved revision: 414
Merged at revision: 415
Proposed branch: lp:~dobey/unity-scope-click/missing-reviews
Merge into: lp:unity-scope-click
Diff against target: 66 lines (+14/-14)
2 files modified
libclickscope/click/preview.cpp (+13/-14)
libclickscope/click/preview.h (+1/-0)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/missing-reviews
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+285131@code.launchpad.net

Commit message

Refactor showing review widget to only do work if app is installed.
Add qualifier to only show review widget if app has download_url from store.
Don't check review.rating again to see if review is being submitted or not.

Description of the change

This branch should fix it so that the review entry box is always shown for installed apps in the store scope, and is not shown for side-loaded apps which are not in the store, in the apps scope. Unfortunately, this is all done inside the preview machinery, and very tightly coupled to needing the Qt bridge, so there are no new tests added in this branch, and it has to be tested manually.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
413. By dobey

Don't use the struct initializer here.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
414. By dobey

Use a member variable to cache the details instead.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libclickscope/click/preview.cpp'
2--- libclickscope/click/preview.cpp 2016-01-27 16:50:50 +0000
3+++ libclickscope/click/preview.cpp 2016-02-08 16:24:44 +0000
4@@ -902,37 +902,36 @@
5 }
6 getApplicationUri(manifest, [this, reply, manifest, app_name, &review, userid](const std::string& uri) {
7 populateDetails([this, reply, uri, manifest, app_name](const PackageDetails &details){
8+ cachedDetails = details;
9 store_department(details);
10 pushPackagePreviewWidgets(cachedWidgets, details, createButtons(uri, manifest));
11 },
12 [this, reply, &review, manifest, userid](const ReviewList& reviewlist,
13- click::Reviews::Error error) {
14+ click::Reviews::Error error) {
15 auto reviews = bring_to_front(reviewlist, userid);
16- scopes::PreviewWidgetList review_input;
17- bool has_reviewed = reviews.size() > 0 && reviews.front().reviewer_username == userid;
18+ if (manifest.removable && !cachedDetails.download_url.empty()) {
19+ scopes::PreviewWidgetList review_input;
20+ bool has_reviewed = reviews.size() > 0 && reviews.front().reviewer_username == userid;
21
22- if (has_reviewed) {
23- auto existing_review = reviews.front();
24- reviews.pop_front();
25- qDebug() << "Review for current user already exists, review id:" << existing_review.id;
26- if (manifest.removable) {
27+ if (has_reviewed) {
28+ auto existing_review = reviews.front();
29+ reviews.pop_front();
30+ qDebug() << "Review for current user already exists, review id:" << existing_review.id;
31 scopes::PreviewWidget rating(std::to_string(existing_review.id), "rating-edit"); // pass review id via widget id
32 rating.add_attribute_value("required", scopes::Variant("rating"));
33 rating.add_attribute_value("review", scopes::Variant(existing_review.review_text));
34 rating.add_attribute_value("rating", scopes::Variant(existing_review.rating));
35 rating.add_attribute_value("author", scopes::Variant(existing_review.reviewer_name));
36 review_input.push_back(rating);
37- }
38- } else {
39- if (review.rating == 0 && manifest.removable) {
40+ } else {
41 scopes::PreviewWidget rating("rating", "rating-input");
42 rating.add_attribute_value("required", scopes::Variant("rating"));
43 review_input.push_back(rating);
44 }
45+ cachedWidgets.push(review_input);
46+ cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, review_input);
47+ cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, review_input);
48 }
49- cachedWidgets.push(review_input);
50- cachedWidgets.layout.appendToColumn(cachedWidgets.layout.singleColumn.column1, review_input);
51- cachedWidgets.layout.appendToColumn(cachedWidgets.layout.twoColumns.column1, review_input);
52
53 if (error == click::Reviews::Error::NoError) {
54 auto const revs = reviewsWidgets(reviews);
55
56=== modified file 'libclickscope/click/preview.h'
57--- libclickscope/click/preview.h 2016-01-28 12:30:31 +0000
58+++ libclickscope/click/preview.h 2016-02-08 16:24:44 +0000
59@@ -265,6 +265,7 @@
60 private:
61 scopes::ActionMetadata metadata;
62 CachedPreviewWidgets cachedWidgets;
63+ PackageDetails cachedDetails;
64 };
65
66 class InstalledScopePreview : public PreviewStrategy

Subscribers

People subscribed via source and target branches

to all changes: