Skip to content
Open
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
8 changes: 3 additions & 5 deletions source/features/conversation-activity-filter.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
}

[data-rgh-conversation-activity-filter='hideEventsAndCollapsedComments'] {
[data-rgh-conversation-activity-filter='hideAllNoise'] {
.rgh-conversation-activity-filtered-event,
.rgh-conversation-activity-bot-comment,
.rgh-conversation-activity-collapsed-comment,
Expand All @@ -33,7 +33,7 @@
display: none;
}

&:is([data-rgh-conversation-activity-filter='hideEvents'] *) {
[data-rgh-conversation-activity-filter='hideEvents'] & {
.octicon-eye {
display: none;
}
Expand All @@ -46,9 +46,7 @@
}
}

&:is(
[data-rgh-conversation-activity-filter='hideEventsAndCollapsedComments'] *
) {
[data-rgh-conversation-activity-filter='hideAllNoise'] & {
.octicon-eye {
display: none;
}
Expand Down
15 changes: 10 additions & 5 deletions source/features/conversation-activity-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ const minorFixesIssuePages = [
'https://github.com/refined-github/refined-github/issues/8000',
];

// Keys are used as CSS selectors
const states = {
showAll: 'Show all activities',
hideEvents: 'Hide events',
hideEventsBotsCollapsedComments: 'Hide events, bots, collapsed comments',
hideAllNoise: 'Hide events, bots, collapsed comments',
} as const;

type State = keyof typeof states;
Expand Down Expand Up @@ -65,6 +66,7 @@ const timelineItem = [
// React issue pages
'[data-wrapper-timeline-id]:not([data-wrapper-timeline-id="load-top"])', // Exclude "Load more" button
];
const comment = ['.comment-body', '.react-issue-comment'];

function processTimelineEvent(item: HTMLElement): void {
// Don't hide commits in PR conversation timelines #5581
Expand All @@ -81,7 +83,7 @@ function processSimpleComment(item: HTMLElement): void {
item.classList.add(collapsedClassName);
}

if (getCommentAuthor(item.firstElementChild!).endsWith('[bot]')) {
if (getCommentAuthor($(comment, item)).endsWith('[bot]')) {
item.classList.add(botClassName);
}
}
Expand Down Expand Up @@ -127,7 +129,7 @@ function processItem(item: HTMLElement): void {
processReview(item);
} else if (elementExists('.TimelineItem-badge .octicon-x', item)) {
processDissmissedReviewEvent(item);
} else if (elementExists(['.comment-body', '.react-issue-comment'], item)) {
} else if (elementExists(comment, item)) {
processSimpleComment(item);
} else {
processTimelineEvent(item);
Expand Down Expand Up @@ -290,11 +292,14 @@ function switchToNextFilter(): void {
async function init(signal: AbortSignal): Promise<void> {
currentState = SessionPageSetting.get()
?? (minorFixesIssuePages.some(url => location.href.startsWith(url))
? 'hideEventsBotsCollapsedComments' // Automatically hide resolved comments on "Minor codebase updates and fixes" issue pages
? 'hideAllNoise' // Automatically hide resolved comments on "Minor codebase updates and fixes" issue pages
: 'showAll');

const initialSetupOnce = onetime(() => {
applyState(currentState);
if (currentState !== 'showAll') {
applyState(currentState);
}

registerHotkey('h', switchToNextFilter, {signal});
delegate(`.${menuClass}`, 'itemActivated', handleSelection);
});
Expand Down
Loading