[Notice] Announcing the End of Demo Server [Read me]
Revert "issue: Fix voters bug"
This reverts commit 445f7d3d6a04c0264633746bb140949be1129f90.
@d979ad0b797a2a275ca3742d6161f16b7de093b6
--- app/controllers/VoteApp.java
+++ app/controllers/VoteApp.java
... | ... | @@ -32,7 +32,6 @@ |
32 | 32 |
import utils.RouteUtil; |
33 | 33 |
|
34 | 34 |
import java.util.ArrayList; |
35 |
-import java.util.Iterator; |
|
36 | 35 |
import java.util.List; |
37 | 36 |
import java.util.Set; |
38 | 37 |
|
... | ... | @@ -120,15 +119,16 @@ |
120 | 119 |
} |
121 | 120 |
|
122 | 121 |
public static List<User> getVotersForAvatar(Set<User> voters, int size){ |
123 |
- List<User> userList = new ArrayList<>(); |
|
124 |
- Iterator<User> iterator = voters.iterator(); |
|
125 |
- int index = 0; |
|
122 |
+ return getSubList(voters, 0, size); |
|
123 |
+ } |
|
126 | 124 |
|
127 |
- while( index++ < size && iterator.hasNext() ) { |
|
128 |
- userList.add(iterator.next()); |
|
129 |
- } |
|
125 |
+ public static List<User> getVotersForName(Set<User> voters, int fromIndex, int size){ |
|
126 |
+ return getSubList(voters, fromIndex, fromIndex + size); |
|
127 |
+ } |
|
130 | 128 |
|
131 |
- return userList; |
|
129 |
+ public static Set<User> getVotersExceptCurrentUser(Set<User> voters){ |
|
130 |
+ voters.remove(UserApp.currentUser()); |
|
131 |
+ return voters; |
|
132 | 132 |
} |
133 | 133 |
|
134 | 134 |
/** |
--- app/views/issue/partial_comment.scala.html
+++ app/views/issue/partial_comment.scala.html
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 |
@defining(comment.asInstanceOf[IssueComment]) { issueComment => |
45 | 45 |
@if(issueComment.voters.size > VOTER_AVATAR_SHOW_LIMIT) { |
46 | 46 |
<span style="margin-right: 2px;" data-toggle="tooltip" data-html="true" title=" |
47 |
- @for(voter <- issueComment.voters) { |
|
47 |
+ @for(voter <- VoteApp.getVotersForName(issueComment.voters, 0, 5)) { |
|
48 | 48 |
@voter.name<br> |
49 | 49 |
} |
50 | 50 |
…"> |
--- app/views/issue/partial_voters.scala.html
+++ app/views/issue/partial_voters.scala.html
... | ... | @@ -14,14 +14,14 @@ |
14 | 14 |
<li>@Html(getUserAvatar(UserApp.currentUser, "smaller"))</li> |
15 | 15 |
} |
16 | 16 |
|
17 |
- @defining(issue.voters) { issueVoters => |
|
17 |
+ @defining(VoteApp.getVotersExceptCurrentUser(issue.voters)) { issueVoters => |
|
18 | 18 |
@for(voter <- VoteApp.getVotersForAvatar(issueVoters, numOfAvatars)) { |
19 | 19 |
<li>@Html(getUserAvatar(voter, "smaller"))</li> |
20 | 20 |
} |
21 | 21 |
@if(issueVoters.size > numOfAvatars) { |
22 | 22 |
<li data-toggle="tooltip" data-html="true" |
23 | 23 |
title=" |
24 |
- @for(voter <- issueVoters) { |
|
24 |
+ @for(voter <- VoteApp.getVotersForName(issueVoters, numOfAvatars, numOfNames)) { |
|
25 | 25 |
@voter.name <br> |
26 | 26 |
} |
27 | 27 |
@if(issueVoters.size > numOfAvatars + numOfNames) { |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?