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