Fix setFlag/waitFlag edge case that was causing duplicate joins
This commit is contained in:
parent
e6d6e3391e
commit
565e490078
|
@ -26,14 +26,10 @@ function ActiveLock(channel) {
|
||||||
ActiveLock.prototype = {
|
ActiveLock.prototype = {
|
||||||
lock: function () {
|
lock: function () {
|
||||||
this.count++;
|
this.count++;
|
||||||
//console.log('dbg: lock/count: ', this.count);
|
|
||||||
//console.trace();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
release: function () {
|
release: function () {
|
||||||
this.count--;
|
this.count--;
|
||||||
//console.log('dbg: release/count: ', this.count);
|
|
||||||
//console.trace();
|
|
||||||
if (this.count === 0) {
|
if (this.count === 0) {
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (this.channel.users.length > 0) {
|
if (this.channel.users.length > 0) {
|
||||||
|
@ -87,8 +83,8 @@ Channel.prototype.waitFlag = function (flag, cb) {
|
||||||
if (self.is(flag)) {
|
if (self.is(flag)) {
|
||||||
cb();
|
cb();
|
||||||
} else {
|
} else {
|
||||||
var wait = function () {
|
var wait = function (f) {
|
||||||
if (self.is(flag)) {
|
if (f === flag) {
|
||||||
self.unbind("setFlag", wait);
|
self.unbind("setFlag", wait);
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ User.prototype.waitFlag = function (flag, cb) {
|
||||||
cb();
|
cb();
|
||||||
} else {
|
} else {
|
||||||
var wait = function (f) {
|
var wait = function (f) {
|
||||||
if ((f & flag) === flag) {
|
if (f === flag) {
|
||||||
self.unbind("setFlag", wait);
|
self.unbind("setFlag", wait);
|
||||||
cb();
|
cb();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue