summaryrefslogtreecommitdiffstats
path: root/gerrit-httpd
diff options
context:
space:
mode:
authorJan Opacki <jan.opacki@gmail.com>2013-05-05 15:35:25 +0200
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-05-23 09:42:03 +0000
commit9b426203857c4bac6ea7f0c2f12df0d07effcb62 (patch)
treec23089c6938d5d542e4c88c3a4b9ec7b3b2c63a2 /gerrit-httpd
parent2c7acce786f4e7a83b0888fe9baed5d65114c4a3 (diff)
Refactor highlighting patch sets that have drafts
As suggested in the comments under change I537db90a940c9df7c4b7c28974adac5b29c8abf4: - Remove an unrelated field from a PatchSet entity class - Remove highlighting of the patch set label - Add a "comment" icon to a patch set header to indicate that it has draft comment(s) Bug: Issue 667 Change-Id: Ie37be962ecb7beb82e85174492e154db9df6175c (cherry picked from commit 61e18b0595b48766f4aebe7431f66b012b596a1c)
Diffstat (limited to 'gerrit-httpd')
-rw-r--r--gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java
index 08bcf88629..557e017cac 100644
--- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java
+++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/changedetail/ChangeDetailFactory.java
@@ -177,19 +177,25 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
private void loadPatchSets() throws OrmException {
ResultSet<PatchSet> source = db.patchSets().byChange(changeId);
List<PatchSet> patches = new ArrayList<PatchSet>();
+ Set<PatchSet.Id> patchesWithDraftComments = new HashSet<PatchSet.Id>();
+ final CurrentUser user = control.getCurrentUser();
+ final Account.Id me =
+ user instanceof IdentifiedUser ? ((IdentifiedUser) user).getAccountId()
+ : null;
for (PatchSet ps : source) {
- final CurrentUser user = control.getCurrentUser();
- if (user instanceof IdentifiedUser) {
- final Account.Id me = ((IdentifiedUser) user).getAccountId();
- ps.setHasDraftComments(db.patchComments()
- .draftByPatchSetAuthor(ps.getId(), me).iterator().hasNext());
- }
+ final PatchSet.Id psId = ps.getId();
if (control.isPatchVisible(ps, db)) {
patches.add(ps);
+ if (me != null
+ && db.patchComments().draftByPatchSetAuthor(psId, me)
+ .iterator().hasNext()) {
+ patchesWithDraftComments.add(psId);
+ }
}
- patchsetsById.put(ps.getId(), ps);
+ patchsetsById.put(psId, ps);
}
detail.setPatchSets(patches);
+ detail.setPatchSetsWithDraftComments(patchesWithDraftComments);
}
private void loadMessages() throws OrmException {