Mijeong Park Mijeong Park 2018-03-23
Revert "issue: Fix voters bug"
This reverts commit 445f7d3.
@d979ad0b797a2a275ca3742d6161f16b7de093b6
app/controllers/VoteApp.java
--- app/controllers/VoteApp.java
+++ app/controllers/VoteApp.java
@@ -32,7 +32,6 @@
 import utils.RouteUtil;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -120,15 +119,16 @@
     }
 
     public static List<User> getVotersForAvatar(Set<User> voters, int size){
-        List<User> userList = new ArrayList<>();
-        Iterator<User> iterator = voters.iterator();
-        int index = 0;
+        return getSubList(voters, 0, size);
+    }
 
-        while( index++ < size && iterator.hasNext() ) {
-            userList.add(iterator.next());
-        }
+    public static List<User> getVotersForName(Set<User> voters, int fromIndex, int size){
+        return getSubList(voters, fromIndex, fromIndex + size);
+    }
 
-        return userList;
+    public static Set<User> getVotersExceptCurrentUser(Set<User> voters){
+        voters.remove(UserApp.currentUser());
+        return voters;
     }
 
     /**
app/views/issue/partial_comment.scala.html
--- app/views/issue/partial_comment.scala.html
+++ app/views/issue/partial_comment.scala.html
@@ -44,7 +44,7 @@
                     @defining(comment.asInstanceOf[IssueComment]) { issueComment =>
                         @if(issueComment.voters.size > VOTER_AVATAR_SHOW_LIMIT) {
                             <span style="margin-right: 2px;" data-toggle="tooltip" data-html="true" title="
-                                @for(voter <- issueComment.voters) {
+                                @for(voter <- VoteApp.getVotersForName(issueComment.voters, 0, 5)) {
                                     @voter.name<br>
                                     }
                                 &hellip;">
app/views/issue/partial_voters.scala.html
--- app/views/issue/partial_voters.scala.html
+++ app/views/issue/partial_voters.scala.html
@@ -14,14 +14,14 @@
             <li>@Html(getUserAvatar(UserApp.currentUser, "smaller"))</li>
         }
 
-        @defining(issue.voters) { issueVoters =>
+        @defining(VoteApp.getVotersExceptCurrentUser(issue.voters)) { issueVoters =>
             @for(voter <- VoteApp.getVotersForAvatar(issueVoters, numOfAvatars)) {
                 <li>@Html(getUserAvatar(voter, "smaller"))</li>
             }
             @if(issueVoters.size > numOfAvatars) {
                 <li data-toggle="tooltip" data-html="true"
                     title="
-                    @for(voter <- issueVoters) {
+                    @for(voter <- VoteApp.getVotersForName(issueVoters, numOfAvatars, numOfNames)) {
                         @voter.name <br>
                     }
                     @if(issueVoters.size > numOfAvatars + numOfNames) {
Add a comment
List