From 33dbc80dbc0e74eea7ed374ff12f2ee88aa27733 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Tue, 30 Jan 2018 19:52:52 +0200 Subject: [PATCH] Fix #1991: Wait for server response when parting channels --- src/plugins/inputs/part.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index 3bab3810..1d172935 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -27,17 +27,17 @@ exports.input = function(network, chan, cmd, args) { return; } - network.channels = _.without(network.channels, target); - target.destroy(); - this.emit("part", { - chan: target.id, - }); - this.save(); - - if (target.type === Chan.Type.CHANNEL) { - if (network.irc) { - network.irc.part(target.name, partMessage); - } + // If target is not a channel or we are not connected, instantly remove the channel + // Otherwise send part to the server and wait for response + if (target.type !== Chan.Type.CHANNEL || !network.irc || !network.irc.connection || !network.irc.connection.connected) { + network.channels = _.without(network.channels, target); + target.destroy(); + this.emit("part", { + chan: target.id, + }); + this.save(); + } else { + network.irc.part(target.name, partMessage); } return true;