mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 03:53:08 +00:00
network event: remove unused array
All the network events only ever emit a single copy There's no point in wrapping it into an array
This commit is contained in:
parent
5ee9c2b338
commit
bf7eb0e727
4 changed files with 10 additions and 11 deletions
|
@ -3,7 +3,7 @@ import {store} from "../store";
|
|||
import {switchToChannel} from "../router";
|
||||
|
||||
socket.on("network", function (data) {
|
||||
const network = data.networks[0];
|
||||
const network = data.network;
|
||||
|
||||
network.isJoinChannelShown = false;
|
||||
network.isCollapsed = false;
|
||||
|
|
|
@ -344,7 +344,7 @@ class Client {
|
|||
|
||||
client.networks.push(network);
|
||||
client.emit("network", {
|
||||
networks: [network.getFilteredClone(this.lastActiveChannel, -1)],
|
||||
network: network.getFilteredClone(this.lastActiveChannel, -1),
|
||||
});
|
||||
|
||||
if (!network.validate(client)) {
|
||||
|
|
2
shared/types/socket-events.d.ts
vendored
2
shared/types/socket-events.d.ts
vendored
|
@ -53,7 +53,7 @@ interface ServerToClientEvents {
|
|||
|
||||
names: EventHandler<{id: number; users: SharedUser[]}>;
|
||||
|
||||
network: EventHandler<{networks: SharedNetwork[]}>;
|
||||
network: EventHandler<{network: SharedNetwork}>;
|
||||
"network:options": EventHandler<{network: string; serverOptions: {[key: string]: any}}>;
|
||||
"network:status": EventHandler<{network: string; connected: boolean; secure: boolean}>;
|
||||
"network:info": EventHandler<{uuid: string}>;
|
||||
|
|
|
@ -110,14 +110,13 @@ describe("Server", function () {
|
|||
});
|
||||
|
||||
client.on("network", (data) => {
|
||||
expect(data.networks).to.be.an("array");
|
||||
expect(data.networks).to.have.lengthOf(1);
|
||||
expect(data.networks[0].nick).to.equal("test-user");
|
||||
expect(data.networks[0].name).to.equal("Test Network");
|
||||
expect(data.networks[0].channels).to.have.lengthOf(3);
|
||||
expect(data.networks[0].channels[0].name).to.equal("Test Network");
|
||||
expect(data.networks[0].channels[1].name).to.equal("#thelounge");
|
||||
expect(data.networks[0].channels[2].name).to.equal("#spam");
|
||||
expect(data.network).to.exist;
|
||||
expect(data.network.nick).to.equal("test-user");
|
||||
expect(data.network.name).to.equal("Test Network");
|
||||
expect(data.network.channels).to.have.lengthOf(3);
|
||||
expect(data.network.channels[0].name).to.equal("Test Network");
|
||||
expect(data.network.channels[1].name).to.equal("#thelounge");
|
||||
expect(data.network.channels[2].name).to.equal("#spam");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue