Skip to content

Improve upvote / downvote comment handling - #39

Closed
paulmolluzzo wants to merge 3 commits into
masterfrom
improve-emoji-votes
Closed

paulmolluzzo wants to merge 3 commits into
masterfrom
improve-emoji-votes

Conversation

@paulmolluzzo

Copy link
Copy Markdown
Contributor

This is a WIP to fix #32. It solves 2 of the 3 items, but I don't know how to solve the last one perfectly. If we decide to omit it then maybe this PR is done.

  • Smarter emoji detection

As of the opening of this PR 💯 is an acceptable emoji to upvote. To add more acceptable emoji (or text) it can just be added to those arrays. @SpaceK33z set it up that way to begin with.

  • Count one vote per user. In a PR, a user can first down vote, but after some changes up vote. Only the up vote should count in this scenario.

Now each upvote/downvote is only counted once per user. If the same user upvotes, then downvotes, then upvotes, it should effectively count as a single upvote. Voting 100 times in either direction counts as 1 vote.

Not done:

  • If the upvote / downvote is followed by some text, don't remove the comment but let it count.

edit: not doing this since there are too many circumstances to consider. A comment with just a vote and nothing else is a vote. Everything else should stay.

It's not even just following text that's what you'll find. Sometimes the emoji can be at the end of the text. It can also be in the middle some place. And if you look at this issue you can see that there's even people complaining out all the +1's with no content, and those aren't votes, just arguing about voting. Not sure how to solve that one.

Comment thread extension/content.js Outdated
const getUsername = () => $('meta[name="user-login"]').attr('content');
const uselessContent = {
upvote: {text: ['+1\n'], emoji: [':+1:']},
upvote: {text: ['+1\n'], emoji: [':+1:', ':100:']},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can add 👌 as well.

@hkdobrev

Copy link
Copy Markdown
Contributor

A couple of points:

  • When a comment begins with a mention, I'd say not to count that as upvote or downvote disregarding of the content or emoji. This is most probably a reply to something. Sometimes someone can express negative opinion on something and someone to support this negative opinion by mentioning him and give a 👍 to his comment.
  • I second what @SpaceK33z mentioned in Improve upvote / downvote comment handling #32 (comment). GitHub said they will add some changes to issues which could affect these +/- 1 interactions in substantial way.

@paulmolluzzo

Copy link
Copy Markdown
Contributor Author

I added in the acceptance of 👌 as an upvote and also fixed a bug I found. I also want to point out why this PR is better than just leaving the current implementation. A picture is worth 1000 words, so here are screenshots highlighting the differences. In all of these I'm the only user upvoting and downvoting a bunch of times. I think the PR is a marked improvement.

No extension:

no-extension

Before the PR:

before-this-pr

After the plugin:

after-this-pr


To @hkdobrev's feedback:

When a comment begins with a mention, I'd say not to count that as upvote or downvote disregarding of the content or emoji. This is most probably a reply to something. Sometimes someone can express negative opinion on something and someone to support this negative opinion by mentioning him and give a 👍 to his comment.

This PR doesn't change the way @SpaceK33z decided to include/omit comments for votes. The logic in the commentIsUseless function is that if a comment has nothing but an upvote/downvote it counts, and I left that alone, except now I return false for all non-useless comments to help with some other logic.

I think @SpaceK33z made a good choice there. 👍

I second what @SpaceK33z mentioned in #32 (comment). GitHub said they will add some changes to issues which could affect these +/- 1 interactions in substantial way.

As I understand it, that's sort of the point of this extension. If it breaks because GitHub is improved, so be it.

Relevant part in the README:

My hope is that GitHub will notice and implement some of these much needed improvements. So if you like any of these features, please email GitHub support about adding it.

Comment thread extension/content.js Outdated

const isUp = commentIsUseless('upvote', el);
const isDown = commentIsUseless('downvote', el);
const commenter = el.closest('.js-comment-container').getElementsByClassName('author')[0].innerHTML;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just

const commenter = el.closest('.js-comment-container').find('author').get(0).innerHTML;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see a big difference, but I changed it.

@paulmolluzzo

Copy link
Copy Markdown
Contributor Author

@sindresorhus I think this is complete actually. I don't want to get into comment parsing to leave text or consider the context of the content. That's super complex I think. What about using +1 in a math equation? Or when someone does +1000! Or a phrase like "if you actually make this work then 👍"?

A comment with just a vote and nothing else is a vote. Everything else should stay. What do you think?

@sindresorhus

Copy link
Copy Markdown
Member

A comment with just a vote and nothing else is a vote. Everything else should stay. What do you think?

👍

@paulmolluzzo paulmolluzzo changed the title [WIP] Improve upvote / downvote comment handling Improve upvote / downvote comment handling Feb 26, 2016
@paulmolluzzo

Copy link
Copy Markdown
Contributor Author

OK, updated title and first comment. This should be OK to do a review and merge if it's good.

@sindresorhus
sindresorhus deleted the improve-emoji-votes branch February 26, 2016 15:12
@sindresorhus

Copy link
Copy Markdown
Member

@paulmolluzzo Good stuff :)

hkdobrev added a commit that referenced this pull request Apr 6, 2016
Closes #74.

Removes the work done in: #17, #39 and #73.
hkdobrev added a commit that referenced this pull request Apr 6, 2016
Closes #74.

Removes the work done in: #17, #39 and #73.
hkdobrev added a commit that referenced this pull request Apr 6, 2016
Closes #74.

Removes the work done in: #17, #39 and #73.
sindresorhus pushed a commit that referenced this pull request Apr 7, 2016
Closes #74.



Removes the work done in: #17, #39 and #73.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Improve upvote / downvote comment handling

3 participants