Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse some events in discussions #2201

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.rgh-useless-comments-note {
.rgh-noisy-discussion-note {
margin: 15px 0 10px 60px;
font-size: 12px;
color: #586069;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import './hide-useless-comments.css';
import './hide-discussion-noise.css';
import React from 'dom-chef';
import select from 'select-dom';
import features from '../libs/features';
import {isIssue} from '../libs/page-detect';

function init(): void {
let uselessCount = 0;
function hideComments(): number {
let hiddenCommentsCount = 0;
for (const commentText of select.all('.comment-body > p:only-child')) {
// Find useless comments
if (!/^([+-]\d+!*|👍|🙏|👎|👌|)+$/.test(commentText.textContent!.trim())) {
Expand Down Expand Up @@ -33,13 +34,19 @@ function init(): void {

comment.hidden = true;
comment.classList.add('rgh-hidden-comment');
uselessCount++;
hiddenCommentsCount++;
}

if (uselessCount > 0) {
return hiddenCommentsCount;
}

function init(): void {
// Only hide comments in issues #1543
const hiddenCommentsCount = isIssue() ? hideComments() : 0;
if (hiddenCommentsCount > 0) {
select('.discussion-timeline-actions')!.prepend(
<p className="rgh-useless-comments-note">
{`${uselessCount} unhelpful comment${uselessCount > 1 ? 's were' : ' was'} automatically hidden. `}
<p className="rgh-noisy-discussion-note">
{`${hiddenCommentsCount} unhelpful comment${hiddenCommentsCount > 1 ? 's were' : ' was'} automatically hidden. `}
<button className="btn-link text-emphasized" onClick={unhide}>Show</button>
</p>
);
Expand All @@ -59,7 +66,8 @@ features.add({
id: __featureName__,
description: 'Hide useless comments like "+1"',
include: [
features.isIssue
features.isIssue,
features.isPRConversation
],
load: features.onAjaxedPages,
init
Expand Down
1 change: 1 addition & 0 deletions source/options-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default new OptionsSync({

featureWasRenamed('move-marketplace-link-to-profile-dropdown', 'deprioritize-marketplace-link'), // Merged on June 7th
featureWasRenamed('show-asset-download-count', 'release-download-count'), // Merged on June 9th
featureWasRenamed('hide-useless-comments', 'hide-discussion-noise'), // Merged on July 9th

// Removed features will be automatically removed from the options as well
OptionsSync.migrations.removeUnused
Expand Down