Skip to content

feat: collapse downvoted comments by default when setting (default off) is set#1860

Open
jameslounds wants to merge 5 commits intoaeharding:mainfrom
jameslounds:feat/collapse-downvoted-comments
Open

feat: collapse downvoted comments by default when setting (default off) is set#1860
jameslounds wants to merge 5 commits intoaeharding:mainfrom
jameslounds:feat/collapse-downvoted-comments

Conversation

@jameslounds
Copy link

@jameslounds jameslounds commented Feb 21, 2025

Closes #1838

This is my first contribution, so it's very possible I've misunderstood something or not followed conventions in the project. As well as more substantive feedback, nitpicks are more than welcome - they help me learn!

About the `ppm-lcck.yaml` update (reverted)

Also not entirely sure why, but the pnpm-lock.yaml needed updating. pnpm i --frozen-lockfile gave an error

❯ pnpm i --frozen-lockfile
 ERR_PNPM_LOCKFILE_CONFIG_MISMATCH  Cannot proceed with the frozen installation. The current "patchedDependencies" configuration doesn't match the value found in the lockfile

Update your lockfile using "pnpm install --no-frozen-lockfile"

It seems that the CI won't pass with my updated lockfile (with the same error I get using the main lockfile).

The setting is off by default.

I've added hasUserCollapsed which is true if the value for commentId in state.comment.commentCollapsedById has been defined. If it hasn't we're in the initial state of the comment (uncollapsed unless downvoted & setting is set). If it has, the user must have shown/hidden the comment so we should use the state from state.comment.commentCollapsedById rather than the default.

@jameslounds jameslounds changed the title Feat: Collapse downvoted comments by default when setting (default off) is set feat: Collapse downvoted comments by default when setting (default off) is set Feb 21, 2025
This reverts commit c1b5630.
@jameslounds jameslounds changed the title feat: Collapse downvoted comments by default when setting (default off) is set feat: collapse downvoted comments by default when setting (default off) is set Feb 21, 2025
Copy link
Owner

@aeharding aeharding left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I tried it out. I really like it, seems to clean up the comments section a good amount.

However, I did find a bug: The first time I tap to expand an auto collapsed comment, it doesn't expand. It does on the second try, though.

LMK if you have any questions I'm happy to help

}: CommentTreeProps) {
const dispatch = useAppDispatch();
const commentId = comment.comment_view.comment.id;
const hasUserCollapsed = useAppSelector((state) =>
Copy link
Owner

Choose a reason for hiding this comment

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

Remove this selector and check if collapsed == null

(state) => state.settings.general.comments.downvotedCollapsedByDefault,
);

const isDownvoted =
Copy link
Owner

Choose a reason for hiding this comment

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

Check if counts.score < 0 instead

dispatch(setDownvotedCollapsedByDefault(e.detail.checked))
}
>
Collapse Downvoted Comments
Copy link
Owner

Choose a reason for hiding this comment

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

I was initially confused by this! I thought it would collapse when I downvote. Instead, it collapses comments with negative cumulative vote (which makes more sense!).

I think we should come up with a different setting that avoids this confusion. Some options...

as a switch, "Auto Collapse Negative Votes"

or, as a dropdown with options:

"Collapse Downvoted Comments..."

  • "When Negative"
  • "When Highly Downvoted" (some cool algorithm we build hehe)
  • "Never" (default)

I personally prefer the latter, and it opens the door for more customization. What are your thoughts?

general: {
comments: {
collapseCommentThreads: OCommentThreadCollapse.Never,
downvotedCollapsedByDefault: false,
Copy link
Owner

Choose a reason for hiding this comment

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

nit: remove 'ByDefault'

@aeharding aeharding force-pushed the main branch 4 times, most recently from 12e8b8c to 4efb2fc Compare March 15, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto hide downvoted comments

2 participants