summaryrefslogtreecommitdiff
path: root/source/features/minimize-user-comments.tsx
diff options
context:
space:
mode:
authorGravatar sharkykh <sharkykh@gmail.com> 2019-08-02 20:53:17 +0300
committerGravatar Federico Brigante <github@bfred.it> 2019-08-03 00:53:17 +0700
commit7db0c217842e3eb05a38aefd97743b7f0ea9963e (patch)
treea3d5b90d4fff435af902a5ef4ab906fd7c4083b6 /source/features/minimize-user-comments.tsx
parentf36d4f10c725b4511e0d28d5c1fec2cf1b2a22b6 (diff)
downloadrefined-github-7db0c217842e3eb05a38aefd97743b7f0ea9963e.tar.gz
refined-github-7db0c217842e3eb05a38aefd97743b7f0ea9963e.tar.zst
refined-github-7db0c217842e3eb05a38aefd97743b7f0ea9963e.zip
Fix `minimize-user-comments` feature (#2297)
Diffstat (limited to 'source/features/minimize-user-comments.tsx')
-rw-r--r--source/features/minimize-user-comments.tsx13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/features/minimize-user-comments.tsx b/source/features/minimize-user-comments.tsx
index 90c73dc9..405eb40d 100644
--- a/source/features/minimize-user-comments.tsx
+++ b/source/features/minimize-user-comments.tsx
@@ -48,7 +48,7 @@ async function onButtonClick(event: React.MouseEvent<HTMLButtonElement>): Promis
}
async function handleMenuOpening(event: DelegateEvent): Promise<void> {
- const dropdown = event.delegateTarget.nextElementSibling!;
+ const dropdown = event.delegateTarget.nextElementSibling as HTMLElement;
const user = getUsernameFromComment(dropdown.closest('.js-targetable-comment')!);
if (user === getUsername()) {
return;
@@ -73,22 +73,25 @@ async function handleMenuOpening(event: DelegateEvent): Promise<void> {
{getLabel(shouldMinimizeComment)}
</button>
);
+
+ // The new button's label is too long for the dropdown
+ dropdown.style.width = '205px';
}
async function minimizeMutedUserComments(): Promise<void> {
const minimizedUsers = await getMinimizedUsers();
for (const comment of select.all('.js-discussion .js-minimizable-comment-group')) {
- if (minimizedUsers.includes(getUsernameFromComment(comment))) {
- toggleComment(comment, true);
- }
+ const user = getUsernameFromComment(comment);
+ toggleComment(comment, minimizedUsers.includes(user));
}
}
function init(): void {
minimizeMutedUserComments();
onNewComments(minimizeMutedUserComments);
- delegate('.timeline-comment-action', 'click', handleMenuOpening);
+ // `summary` excludes the `edit-comments-faster` button
+ delegate('summary.timeline-comment-action:not([aria-label="Add your reaction"])', 'click', handleMenuOpening);
}
features.add({