2017-05-18 21:08:54 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const socket = require("../socket");
|
2019-11-02 20:45:00 +02:00
|
|
|
const {vueApp, initChannel, findChannel, findNetwork} = require("../vue");
|
2019-11-02 21:40:59 +02:00
|
|
|
const store = require("../store").default;
|
2017-05-18 21:08:54 +01:00
|
|
|
|
|
|
|
socket.on("network", function(data) {
|
2018-07-12 21:33:52 +03:00
|
|
|
const network = data.networks[0];
|
2017-05-18 21:08:54 +01:00
|
|
|
|
2018-07-12 22:06:17 +03:00
|
|
|
network.isJoinChannelShown = false;
|
|
|
|
network.isCollapsed = false;
|
2018-07-18 21:40:09 +03:00
|
|
|
network.channels.forEach(initChannel);
|
2018-07-12 22:06:17 +03:00
|
|
|
|
2019-11-02 21:40:59 +02:00
|
|
|
store.commit("networks", [...store.state.networks, network]);
|
2019-10-25 21:37:40 +00:00
|
|
|
vueApp.switchToChannel(network.channels[0]);
|
2017-05-18 21:08:54 +01:00
|
|
|
});
|
|
|
|
|
2018-07-19 20:44:24 +03:00
|
|
|
socket.on("network:options", function(data) {
|
2019-11-02 21:40:59 +02:00
|
|
|
const network = findNetwork(data.network);
|
|
|
|
|
|
|
|
if (network) {
|
|
|
|
network.serverOptions = data.serverOptions;
|
|
|
|
}
|
2017-05-18 21:08:54 +01:00
|
|
|
});
|
2018-02-19 13:12:01 +02:00
|
|
|
|
|
|
|
socket.on("network:status", function(data) {
|
2019-11-02 21:40:59 +02:00
|
|
|
const network = findNetwork(data.network);
|
2018-09-19 17:48:13 +03:00
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-06 21:15:15 +03:00
|
|
|
network.status.connected = data.connected;
|
|
|
|
network.status.secure = data.secure;
|
2018-07-19 21:03:53 +03:00
|
|
|
|
|
|
|
if (!data.connected) {
|
2018-08-24 11:29:03 +03:00
|
|
|
network.channels.forEach((channel) => {
|
|
|
|
channel.users = [];
|
|
|
|
channel.state = 0;
|
|
|
|
});
|
2018-07-19 21:03:53 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("channel:state", function(data) {
|
|
|
|
const channel = findChannel(data.chan);
|
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
channel.channel.state = data.state;
|
|
|
|
}
|
2018-02-19 13:12:01 +02:00
|
|
|
});
|
2018-03-15 10:37:32 +02:00
|
|
|
|
|
|
|
socket.on("network:info", function(data) {
|
2019-11-02 20:45:00 +02:00
|
|
|
const network = findNetwork(data.uuid);
|
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
vueApp.$set(network, key, data[key]);
|
|
|
|
}
|
2018-03-15 10:37:32 +02:00
|
|
|
});
|