Skip to content

Commit 8b65f6b

Browse files
committed
Issue-comments: Fix avatar toggle & append new on update
1 parent ea02975 commit 8b65f6b

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

github-issue-comments.user.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@
221221
</div>
222222
<div class="select-menu-list ghic-menu" role="menu">
223223
${list}
224-
<div class="ghic-participants"></div>
224+
<div class="ghic-participants">
225+
<p><strong>Hide Comments from</strong></p>
226+
<div class="ghic-list"></div>
227+
</div>
225228
</div>
226229
</div>
227230
</div>
@@ -239,11 +242,11 @@
239242

240243
function addAvatars() {
241244
let indx = 0,
242-
243-
str = "<p><strong>Hide Comments from</strong></p>",
245+
str = "",
244246
unique = [],
245247
// get all avatars
246248
avatars = $$(".timeline-comment-avatar img"),
249+
list = $(".ghic-list"),
247250
len = avatars.length - 1, // last avatar is the new comment with the current user
248251

249252
loop = (callback) => {
@@ -255,7 +258,7 @@
255258
}
256259
el = avatars[indx];
257260
name = (el.getAttribute("alt") || "").replace("@", "");
258-
if (!unique.includes(name)) {
261+
if (!unique.includes(name) && !$(`.ghic-avatar[aria-label="${name}"]`, list)) {
259262
str += `<span class="ghic-avatar tooltipped tooltipped-n" aria-label="${name}">
260263
${iconHidden}
261264
<img class="ghic-avatar avatar" width="24" height="24" src="${el.src}"/>
@@ -274,7 +277,11 @@
274277
}
275278
};
276279
loop(() => {
277-
$(".ghic-participants").innerHTML = str;
280+
if ($(".ghic-avatar", list)) {
281+
list.innerHTML += str;
282+
} else {
283+
list.innerHTML = str;
284+
}
278285
});
279286
}
280287

@@ -546,14 +553,15 @@
546553
// true flag for init - no need to remove classes
547554
hideStuff(keys[indx], true);
548555
}
556+
addAvatars();
549557
}
550558
}
551559

552560
function checkItem(event) {
553561
if (document.getElementById("discussion_bucket")) {
554562
let name,
555563
target = event.target,
556-
wrap = target && target.closest(".dropdown-item");
564+
wrap = target && target.closest(".dropdown-item, .ghic-participants");
557565
if (target && wrap) {
558566
if (target.nodeName === "INPUT") {
559567
getInputValues();

0 commit comments

Comments
 (0)