Skip to content

Node.js based forum software built for the modern web

added comments to explain the voting logic

Julian Lam86a697960696
diff --git a/src/favourites.js b/src/favourites.js
index 4f5ff90274..0673626f51 100644
--- a/src/favourites.js
+++ b/src/favourites.js
@@ -183,11 +183,11 @@ var async = require('async'),
hook,
current = voteStatus.upvoted ? 'upvote' : 'downvote';
- if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') {
+ if (voteStatus.upvoted && command === 'downvote' || voteStatus.downvoted && command === 'upvote') { // e.g. User *has* upvoted, and clicks downvote
hook = command;
- } else if (voteStatus.upvoted || voteStatus.downvoted) {
+ } else if (voteStatus.upvoted || voteStatus.downvoted) { // e.g. User *has* upvotes, clicks upvote (so we "unvote")
hook = 'unvote';
- } else {
+ } else { // e.g. User *has not* voted, clicks upvote
hook = command;
current = 'unvote';
}