Sync changed network name to open clients
This commit is contained in:
parent
1ef7d5ed49
commit
67e4a4bbb2
@ -64,3 +64,8 @@ socket.on("network:info", function (data) {
|
||||
Vue.set(network, key, data[key]);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("network:name", function (data) {
|
||||
const network = store.getters.findNetwork(data.uuid);
|
||||
network.name = network.channels[0].name = data.name;
|
||||
});
|
||||
|
@ -253,6 +253,7 @@ Network.prototype.createWebIrc = function (client) {
|
||||
};
|
||||
|
||||
Network.prototype.edit = function (client, args) {
|
||||
const oldNetworkName = this.name;
|
||||
const oldNick = this.nick;
|
||||
const oldRealname = this.realname;
|
||||
|
||||
@ -279,6 +280,14 @@ Network.prototype.edit = function (client, args) {
|
||||
// Sync lobby channel name
|
||||
this.channels[0].name = this.name;
|
||||
|
||||
if (this.name !== oldNetworkName) {
|
||||
// Send updated network name to all connected clients
|
||||
client.emit("network:name", {
|
||||
uuid: this.uuid,
|
||||
name: this.name,
|
||||
});
|
||||
}
|
||||
|
||||
if (!this.validate(client)) {
|
||||
return;
|
||||
}
|
||||
|
@ -109,10 +109,18 @@ describe("Network", function () {
|
||||
|
||||
it("editing a network should enforce correct types", function () {
|
||||
let saveCalled = false;
|
||||
let nameEmitCalled = false;
|
||||
|
||||
const network = new Network();
|
||||
network.edit(
|
||||
{
|
||||
emit(name, data) {
|
||||
if (name === "network:name") {
|
||||
nameEmitCalled = true;
|
||||
expect(data.uuid).to.equal(network.uuid);
|
||||
expect(data.name).to.equal("Lounge Test Network");
|
||||
}
|
||||
},
|
||||
save() {
|
||||
saveCalled = true;
|
||||
},
|
||||
@ -133,12 +141,13 @@ describe("Network", function () {
|
||||
commands: "/command 1 2 3\r\n/ping HELLO\r\r\r\r/whois test\r\n\r\n",
|
||||
ip: "newIp",
|
||||
hostname: "newHostname",
|
||||
guid: "newGuid",
|
||||
uuid: "newuuid",
|
||||
}
|
||||
);
|
||||
|
||||
expect(saveCalled).to.be.true;
|
||||
expect(network.guid).to.not.equal("newGuid");
|
||||
expect(nameEmitCalled).to.be.true;
|
||||
expect(network.uuid).to.not.equal("newuuid");
|
||||
expect(network.ip).to.be.undefined;
|
||||
expect(network.hostname).to.be.undefined;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user