From 13f5e3a2c830a8d21a7a64841769a7e50e6b9645 Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 31 May 2014 10:31:45 -0400 Subject: [PATCH] fix? #371 coming out of afk doesn't enable voteskip button if it's on the same media --- lib/channel/voteskip.js | 17 +++++++++++++++++ lib/user.js | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/channel/voteskip.js b/lib/channel/voteskip.js index 171a4281..28eb5bb2 100644 --- a/lib/channel/voteskip.js +++ b/lib/channel/voteskip.js @@ -14,6 +14,15 @@ VoteskipModule.prototype.onUserPostJoin = function (user) { user.socket.on("voteskip", this.handleVoteskip.bind(this, user)); }; +VoteskipModule.prototype.onUserPart = function(user) { + if (!this.poll) { + return; + } + + this.unvote(user.ip); + this.update(); +}; + VoteskipModule.prototype.handleVoteskip = function (user) { if (!this.channel.modules.options.get("allow_voteskip")) { return; @@ -44,6 +53,14 @@ VoteskipModule.prototype.handleVoteskip = function (user) { this.update(); }; +VoteskipModule.prototype.unvote = function(ip) { + if (!this.poll) { + return; + } + + this.poll.unvote(ip); +}; + VoteskipModule.prototype.update = function () { if (!this.channel.modules.options.get("allow_voteskip")) { return; diff --git a/lib/user.js b/lib/user.js index d82727d6..e450829e 100644 --- a/lib/user.js +++ b/lib/user.js @@ -175,8 +175,8 @@ User.prototype.setAFK = function (afk) { if (afk) { this.setFlag(Flags.U_AFK); - if (this.channel.voteskip) { - this.channel.voteskip.unvote(this.ip); + if (this.channel.modules.voteskip) { + this.channel.modules.voteskip.unvote(this.ip); } } else { this.clearFlag(Flags.U_AFK);