@@ -11,7 +11,7 @@ const isReleases = () => isRepo && /^\/[^/]+\/[^/]+\/(releases|tags)/.test(locat
11
11
const isBlame = ( ) => isRepo && / ^ \/ [ ^ / ] + \/ [ ^ / ] + \/ b l a m e \/ / . test ( location . pathname ) ;
12
12
const getUsername = ( ) => $ ( 'meta[name="user-login"]' ) . attr ( 'content' ) ;
13
13
const uselessContent = {
14
- upvote : { text : [ '+1\n' ] , emoji : [ ':+1:' ] } ,
14
+ upvote : { text : [ '+1\n' ] , emoji : [ ':+1:' , ':100:' , ':ok_hand:' ] } ,
15
15
downvote : { text : [ '-1\n' ] , emoji : [ ':-1:' ] }
16
16
} ;
17
17
@@ -49,6 +49,8 @@ function commentIsUseless(type, el) {
49
49
}
50
50
}
51
51
}
52
+
53
+ return false ;
52
54
}
53
55
54
56
function renderVoteCount ( type , count ) {
@@ -68,24 +70,41 @@ function renderVoteCount(type, count) {
68
70
}
69
71
70
72
function moveVotes ( ) {
71
- let upCount = 0 ;
72
- let downCount = 0 ;
73
+ const upVoters = new Set ( ) ;
74
+ const downVoters = new Set ( ) ;
73
75
$ ( '.js-comment-body' ) . each ( ( i , el ) => {
76
+ // this is a comment not in the usual container - found on inline comments
77
+ if ( ! $ ( el ) . closest ( '.js-comment-container' ) ) {
78
+ return ;
79
+ }
80
+
74
81
const isUp = commentIsUseless ( 'upvote' , el ) ;
75
82
const isDown = commentIsUseless ( 'downvote' , el ) ;
83
+ const commenter = $ ( el ) . closest ( '.js-comment-container' ) . find ( '.author' ) . get ( 0 ) . innerHTML ;
76
84
77
85
if ( isUp || isDown ) {
78
- el . closest ( '.js-comment-container' ) . remove ( ) ;
86
+ // remove from both arrays
87
+ upVoters . delete ( commenter ) ;
88
+ downVoters . delete ( commenter ) ;
79
89
80
- upCount += isUp ? 1 : 0 ;
81
- downCount += isDown ? 1 : 0 ;
90
+ // add to upvoters if it's an upvote
91
+ if ( isUp ) {
92
+ upVoters . add ( commenter ) ;
93
+ }
94
+
95
+ // add to upvoters if it's an upvote
96
+ if ( isDown ) {
97
+ downVoters . add ( commenter ) ;
98
+ }
99
+
100
+ el . closest ( '.js-comment-container' ) . remove ( ) ;
82
101
}
83
102
} ) ;
84
- if ( upCount > 0 ) {
85
- renderVoteCount ( 'upvote' , upCount ) ;
103
+ if ( upVoters . size > 0 ) {
104
+ renderVoteCount ( 'upvote' , upVoters . size ) ;
86
105
}
87
- if ( downCount > 0 ) {
88
- renderVoteCount ( 'downvote' , downCount ) ;
106
+ if ( downVoters . size > 0 ) {
107
+ renderVoteCount ( 'downvote' , downVoters . size ) ;
89
108
}
90
109
}
91
110
0 commit comments