2019-11-16 18:24:03 +01:00
|
|
|
import socket from "../socket";
|
2022-05-24 08:35:28 +02:00
|
|
|
import {store} from "../store";
|
2017-05-18 22:08:54 +02:00
|
|
|
|
2020-03-21 21:55:36 +01:00
|
|
|
socket.on("users", function (data) {
|
2019-11-02 20:40:59 +01:00
|
|
|
if (store.state.activeChannel && store.state.activeChannel.channel.id === data.chan) {
|
2018-07-08 14:18:17 +02:00
|
|
|
return socket.emit("names", {
|
2017-11-15 07:35:15 +01:00
|
|
|
target: data.chan,
|
2017-05-18 22:08:54 +02:00
|
|
|
});
|
2018-07-08 14:18:17 +02:00
|
|
|
}
|
|
|
|
|
2019-11-03 15:59:43 +01:00
|
|
|
const channel = store.getters.findChannel(data.chan);
|
2018-07-08 14:18:17 +02:00
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
channel.channel.usersOutdated = true;
|
2017-05-18 22:08:54 +02:00
|
|
|
}
|
|
|
|
});
|
2022-06-02 07:35:01 +02:00
|
|
|
|
|
|
|
socket.on("users:online", ({changedChannels, networkId}) => {
|
|
|
|
for (const network of store.state.networks) {
|
|
|
|
if (network.uuid === networkId) {
|
|
|
|
for (const channel of network.channels) {
|
|
|
|
if (changedChannels.includes(channel.name)) {
|
|
|
|
channel.isOnline = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("users:offline", function ({changedChannels, networkId}) {
|
|
|
|
for (const network of store.state.networks) {
|
|
|
|
if (network.uuid === networkId) {
|
|
|
|
for (const channel of network.channels) {
|
|
|
|
if (changedChannels.includes(channel.name)) {
|
|
|
|
channel.isOnline = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|