voteskip: add early exit for duplicate votes

This commit is contained in:
Calvin Montgomery 2018-11-11 16:08:00 -08:00
parent f6a58d00b2
commit 2d6af31c00
3 changed files with 7 additions and 2 deletions

View file

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.60.0",
"version": "3.60.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View file

@ -40,7 +40,10 @@ VoteskipModule.prototype.handleVoteskip = function (user) {
this.poll = new Poll("[server]", "voteskip", ["skip"], false);
}
this.poll.vote(user.realip, 0);
if (!this.poll.vote(user.realip, 0)) {
// Vote was already recorded for this IP, no update needed
return;
}
var title = "";
if (this.channel.modules.playlist.current) {

View file

@ -24,7 +24,9 @@ Poll.prototype.vote = function(ip, option) {
if(!(ip in this.votes) || this.votes[ip] == null) {
this.votes[ip] = option;
this.counts[option]++;
return true;
}
return false;
};
Poll.prototype.unvote = function(ip) {