mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 12:33:07 +00:00
Merge pull request #4038 from thelounge/xpaw/sync-network-name
Sync changed network name to open clients
This commit is contained in:
commit
3557bf00fd
3 changed files with 25 additions and 2 deletions
|
@ -64,3 +64,8 @@ socket.on("network:info", function (data) {
|
||||||
Vue.set(network, key, data[key]);
|
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) {
|
Network.prototype.edit = function (client, args) {
|
||||||
|
const oldNetworkName = this.name;
|
||||||
const oldNick = this.nick;
|
const oldNick = this.nick;
|
||||||
const oldRealname = this.realname;
|
const oldRealname = this.realname;
|
||||||
|
|
||||||
|
@ -279,6 +280,14 @@ Network.prototype.edit = function (client, args) {
|
||||||
// Sync lobby channel name
|
// Sync lobby channel name
|
||||||
this.channels[0].name = this.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)) {
|
if (!this.validate(client)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,10 +109,18 @@ describe("Network", function () {
|
||||||
|
|
||||||
it("editing a network should enforce correct types", function () {
|
it("editing a network should enforce correct types", function () {
|
||||||
let saveCalled = false;
|
let saveCalled = false;
|
||||||
|
let nameEmitCalled = false;
|
||||||
|
|
||||||
const network = new Network();
|
const network = new Network();
|
||||||
network.edit(
|
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() {
|
save() {
|
||||||
saveCalled = true;
|
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",
|
commands: "/command 1 2 3\r\n/ping HELLO\r\r\r\r/whois test\r\n\r\n",
|
||||||
ip: "newIp",
|
ip: "newIp",
|
||||||
hostname: "newHostname",
|
hostname: "newHostname",
|
||||||
guid: "newGuid",
|
uuid: "newuuid",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(saveCalled).to.be.true;
|
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.ip).to.be.undefined;
|
||||||
expect(network.hostname).to.be.undefined;
|
expect(network.hostname).to.be.undefined;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue