Skip to content

Conversation

@cheap-glitch
Copy link
Contributor

@cheap-glitch cheap-glitch commented Oct 12, 2021

@cheap-glitch cheap-glitch marked this pull request as draft October 12, 2021 08:53
Comment on lines 11 to 13
const comment = select('.comment-body', details);
/* Review comments are loaded asynchronously */
if (!comment) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of checking if each details contains a .comment-body, it'd be more efficient to select those and then use .closest('details').

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a note on hidden review comments: they're not loaded with the page, but only when first expanded... except when the link has a hash pointing to a review comment in the same discussion:

Copy link
Member

@fregante fregante Oct 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a note on hidden review comments: they're not loaded with the page, but only when first expanded... except when the link has a hash pointing to a review comment in the same discussion:

In that case it's no longer hidden, which we don't care about.

If they're all hidden, then they should just be excluded, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case it's no longer hidden, which we don't care about.

Just to be perfectly clear: hidden review comments do get loaded without needing to be opened first (meaning they can be previewed), but only when focusing another review comment in the same subthread (e.g. when following a link ending with #discussion_r<id>).

In all other cases the feature would be almost useless, since the comments need to be loaded first by opening them. (One could argue that it might be useful to be able to preview comments that have been opened up and then hidden again, if there's a lot of them.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the JS comment with this information? It makes it sounds like all review comments are to be excluded

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of checking if each details contains a .comment-body, it'd be more efficient to select those directly and then use .closest('details')

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of checking if each details contains a .comment-body, it'd be more efficient to select those and then use .closest('details').

Yes 👍

@cheap-glitch cheap-glitch marked this pull request as ready for review October 12, 2021 08:59
@cheap-glitch
Copy link
Contributor Author

Unrelated but I just noticed hiding review comments doesn't work anymore. This is a GitHub bug btw 🤦

@cheap-glitch cheap-glitch changed the title Fix preview-hidden-comments feature on review comments Fix preview-hidden-comments on review comments Oct 13, 2021
Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cheap-glitch cheap-glitch merged commit 9e2bf1a into main Oct 14, 2021
@cheap-glitch cheap-glitch deleted the fix-preview-hidden-comments branch October 14, 2021 10:49
cheap-glitch added a commit that referenced this pull request Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

preview-hidden-comments includes the whole comment in the preview

3 participants