Skip to content

Commit bfc8c11

Browse files
authored
Enable reaction-avatars on organization discussions (refined-github#6316)
1 parent fc50289 commit bfc8c11

3 files changed

Lines changed: 22 additions & 26 deletions

File tree

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"filter-altered-clicks": "^2.0.0",
5656
"fit-textarea": "^2.0.0",
5757
"flat-zip": "^1.0.1",
58-
"github-url-detection": "^6.1.0",
58+
"github-url-detection": "^7.0.1-0",
5959
"image-promise": "^7.0.1",
6060
"indent-textarea": "^2.1.1",
6161
"js-abbreviation-number": "^1.4.0",

source/features/reactions-avatars.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const viewportObserver = new IntersectionObserver(changes => {
5858
});
5959

6060
function showAvatarsOn(commentReactions: Element): void {
61-
const avatarLimit = arbitraryAvatarLimit - (commentReactions.children.length * approximateHeaderLength);
61+
const reactionTypes = select.all('.social-reaction-summary-item', commentReactions).length;
62+
const avatarLimit = arbitraryAvatarLimit - (reactionTypes * approximateHeaderLength);
6263

6364
const participantByReaction = select
6465
.all(':scope > button.social-reaction-summary-item', commentReactions)
@@ -74,35 +75,30 @@ function showAvatarsOn(commentReactions: Element): void {
7475
}
7576
}
7677

77-
// TODO [2022-12-18]: Drop `.comment-reactions-options` (GHE)
78-
const reactionsSelector = '.has-reactions :is(.js-comment-reactions-options, .comment-reactions-options):not(.rgh-reactions)';
79-
8078
function observeCommentReactions(commentReactions: Element): void {
81-
commentReactions.classList.add('rgh-reactions');
8279
viewportObserver.observe(commentReactions);
8380
}
8481

8582
function init(signal: AbortSignal): void {
86-
observe(reactionsSelector, observeCommentReactions, {signal});
87-
onAbort(signal, viewportObserver);
88-
}
89-
90-
function discussionInit(signal: AbortSignal): void {
91-
observe(reactionsSelector, observeCommentReactions, {signal});
83+
observe('.has-reactions .js-comment-reactions-options', observeCommentReactions, {signal});
9284
onAbort(signal, viewportObserver);
9385
}
9486

9587
void features.add(import.meta.url, {
9688
include: [
9789
pageDetect.hasComments,
9890
pageDetect.isReleasesOrTags,
99-
],
100-
awaitDomReady: false,
101-
init,
102-
}, {
103-
include: [
10491
pageDetect.isDiscussion,
10592
],
10693
awaitDomReady: false,
107-
init: discussionInit,
94+
init,
10895
});
96+
97+
/*
98+
Test URLs
99+
100+
https://github.com/refined-github/refined-github/pull/4119
101+
https://github.com/parcel-bundler/parcel/discussions/6490
102+
https://github.com/orgs/community/discussions/11202
103+
104+
*/

0 commit comments

Comments
 (0)