Fix voteskip issue when there are no videos left

This commit is contained in:
Calvin Montgomery 2017-03-21 20:04:06 -07:00
parent 309cd40da2
commit 7595faf11d
3 changed files with 85 additions and 4 deletions

View file

@ -75,13 +75,14 @@ VoteskipModule.prototype.update = function () {
return;
}
this.sendVoteskipData(this.channel.users);
var max = this.calcVoteskipMax();
var need = Math.ceil(max * this.channel.modules.options.get("voteskip_ratio"));
if (this.poll.counts[0] >= need) {
this.channel.logger.log("[playlist] Voteskip passed.");
this.reset();
this.channel.modules.playlist._playNext();
} else {
this.sendVoteskipData(this.channel.users);
}
};
@ -115,9 +116,13 @@ VoteskipModule.prototype.calcVoteskipMax = function () {
}, 0);
};
VoteskipModule.prototype.onMediaChange = function (data) {
VoteskipModule.prototype.reset = function reset() {
this.poll = false;
this.sendVoteskipData(this.channel.users);
};
VoteskipModule.prototype.onMediaChange = function (data) {
this.reset();
};
module.exports = VoteskipModule;