-
Notifications
You must be signed in to change notification settings - Fork 160
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
No unvote button #89
Comments
More info on how unvoting works, in particular for down votes. |
I'm interested in giving this feature a shot. From what I can tell this chunk of code:
Seems to be the Javascript vote logic. Would a rudimentary unvote look something like this?
I'm still getting used to the codebase so anybody with more insight into this please do chime in! 😄 |
Sadly, Javascript is not one of my strengths. (Though I'm learning it for $DAY_JOB..) Most of the code above is for just cosmetic rendering, if I recall correctly. The key is the |
I'm beginning to get a better idea I think... There are various functions like A lot more difficult than simply fiddling with some Javascript... 😅 |
On Tue, Mar 06, 2018 at 01:15:11AM +0000, matt wrote:
A lot more difficult than simply fiddling with some Javascript... :sweat_smile:
Voting in Anarki currently works fine w/o JS. It's only used to cancel browser nav.
Previously I posted a link here to what this functionality looks like on HN.
However, there are some open questions as to how unvoting would work on the back end. One, that comes to mind, is that (if I'm not mistaken) not all votes increments the score of an item (or the karma of the posting user), so unvoting should obviously not decrement a score/karma that the vote didn't increment. Otherwise repeated voting and unvoting could eat away score/karma.
|
In the backend votes aren't just counted. Instead, each item contains a list of profiles who voted on it, and each profile has a list of (recent) items they voted on. I imagine (though I haven't actually checked) that you just have to |
On Tue, Mar 06, 2018 at 02:38:41PM -0800, Kartik Agaram wrote:
I imagine (though I haven't actually checked) that you just have to `rem` the appropriate item from both. If it doesn't exist the `rem` will just do nothing.
I may be mistaken about this, but I tried faffing about with this a little bit some time ago, and this is how I remember it.
I think it is possible to for someone to cast a vote on a story without that vote incrementing the score. And I don't think it's easy in retrospect to figure out whether a vote has incremented the score; hence the question is: When someone unvotes a story, should a point be subtracted from the score?
A score is not calculated from a list of votes; it is a value that may possibly be incremented when a vote is cast, as can be seen in the use of `++ i!score` in the `vote-for` function.
Therefore I think it may not be enough to just remove the vote from the list(s) of votes, as the score would have to be changed back too, somehow. (At least I think.)
…--
Pelle Hjek
[email protected]
https://news.hjek.tk
|
Ah, you're right. Looking at So perhaps an It's going to be ugly at the start to have all this duplicated code. But once it's working and tested we can think about how to factor out common code. |
Seems to me if the list of users who voted on something is already stored, the information about whether their vote was considered a sockpuppet vote could be stored alongside it. Then you can decrement |
I have taken a shot at unvoting here. I haven't really tested it yet, but it would be nice if anyone would try it out and tell me everything that's wrong with it 🪲 (I haven't added any JavaScript to make it behave smoothly in the browser yet. Also, it may be worth noting that HN has dropped the JS code to update the score.)
I haven't yet touched the format the votes are stored in anywhere. It might be a good idea to remember which votes are sockpupptes, but how? A vote doesn't have an id. And there's not even a vote template. Votes are just scattered information throughout profiles, items and global variables. And there's no way of deriving karma/score from the votes, because karma/score is just state.
That's what I've done. |
Also, HN's JavaScript code is up for grabs when adding this unvoting stuff. As dang writes:
|
@matthewwiese, if you're still interested in doing the JavaScript fiddling part, I think now's the time. |
Unvoting is working decently now in the Knark fork. I think I prefer focusing on actually making the new features, so if someone else feels like porting this to Anarki, that would be great. |
@hjek Apologies for not seeing your reply sooner! Unfortunately, I don't have the time atm to devote to this, despite what I imagine to be a relatively easy fix. |
There's no unvote button after voting for an item. HN has this now, but I can't remember seeing it there before. (I'll keep an eye out to see approximately how long they let you unvote for.)
The text was updated successfully, but these errors were encountered: