Merge pull request #2019 from thelounge/yamanickill/save-queries

Save query channels in user.json
This commit is contained in:
Jérémie Astori 2018-01-30 19:27:28 -05:00 committed by GitHub
commit c605f35335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 7 deletions

View File

@ -179,6 +179,7 @@ Client.prototype.connect = function(args) {
channels.push(new Chan({
name: chan.name,
key: chan.key || "",
type: chan.type,
}));
});

View File

@ -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;

View File

@ -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);
}

View File

@ -50,4 +50,5 @@ exports.input = function(network, chan, cmd, args) {
chan: newChan.getFilteredClone(true),
shouldOpen: true,
});
this.save();
};

View File

@ -41,6 +41,7 @@ describe("Network", function() {
{name: "&foobar", key: ""},
{name: "#secret", key: "foo"},
{name: "&secure", key: "bar"},
{name: "PrivateChat", type: "query"},
],
});
});