Save query channels in user.json

This commit is contained in:
Al McKinlay 2018-01-30 16:46:34 +00:00
parent bc05ca1c63
commit 5cf24b80e6
5 changed files with 12 additions and 7 deletions

View file

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

View file

@ -115,13 +115,16 @@ Network.prototype.export = function() {
network.channels = this.channels network.channels = this.channels
.filter(function(channel) { .filter(function(channel) {
return channel.type === Chan.Type.CHANNEL; return channel.type === Chan.Type.CHANNEL || channel.type === Chan.Type.QUERY;
}) })
.map(function(chan) { .map(function(chan) {
return _.pick(chan, [ const keys = ["name"];
"name", if (chan.type === Chan.Type.CHANNEL) {
"key", keys.push("key");
]); } else if (chan.type === Chan.Type.QUERY) {
keys.push("type");
}
return _.pick(chan, keys);
}); });
return network; return network;

View file

@ -32,10 +32,9 @@ exports.input = function(network, chan, cmd, args) {
this.emit("part", { this.emit("part", {
chan: target.id, chan: target.id,
}); });
this.save();
if (target.type === Chan.Type.CHANNEL) { if (target.type === Chan.Type.CHANNEL) {
this.save();
if (network.irc) { if (network.irc) {
network.irc.part(target.name, partMessage); network.irc.part(target.name, partMessage);
} }

View file

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

View file

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