diff --git a/src/client.js b/src/client.js index e3185a62..3c51741f 100644 --- a/src/client.js +++ b/src/client.js @@ -179,6 +179,7 @@ Client.prototype.connect = function(args) { channels.push(new Chan({ name: chan.name, key: chan.key || "", + type: chan.type, })); }); diff --git a/src/models/network.js b/src/models/network.js index 61da4fed..82eb8eba 100644 --- a/src/models/network.js +++ b/src/models/network.js @@ -115,13 +115,16 @@ Network.prototype.export = function() { network.channels = this.channels .filter(function(channel) { - return channel.type === Chan.Type.CHANNEL; + return channel.type === Chan.Type.CHANNEL || channel.type === Chan.Type.QUERY; }) .map(function(chan) { - return _.pick(chan, [ - "name", - "key", - ]); + const keys = ["name"]; + if (chan.type === Chan.Type.CHANNEL) { + keys.push("key"); + } else if (chan.type === Chan.Type.QUERY) { + keys.push("type"); + } + return _.pick(chan, keys); }); return network; diff --git a/src/plugins/inputs/part.js b/src/plugins/inputs/part.js index e8cdd62b..3bab3810 100644 --- a/src/plugins/inputs/part.js +++ b/src/plugins/inputs/part.js @@ -32,10 +32,9 @@ exports.input = function(network, chan, cmd, args) { this.emit("part", { chan: target.id, }); + this.save(); if (target.type === Chan.Type.CHANNEL) { - this.save(); - if (network.irc) { network.irc.part(target.name, partMessage); } diff --git a/src/plugins/inputs/query.js b/src/plugins/inputs/query.js index 24b3ccdd..85a88310 100644 --- a/src/plugins/inputs/query.js +++ b/src/plugins/inputs/query.js @@ -50,4 +50,5 @@ exports.input = function(network, chan, cmd, args) { chan: newChan.getFilteredClone(true), shouldOpen: true, }); + this.save(); }; diff --git a/test/models/network.js b/test/models/network.js index 97354295..99b28263 100644 --- a/test/models/network.js +++ b/test/models/network.js @@ -41,6 +41,7 @@ describe("Network", function() { {name: "&foobar", key: ""}, {name: "#secret", key: "foo"}, {name: "&secure", key: "bar"}, + {name: "PrivateChat", type: "query"}, ], }); });