Synchornize channel state to the client
This commit is contained in:
parent
f2cbd1efed
commit
853f67ab40
@ -6,6 +6,7 @@
|
||||
<span
|
||||
:title="channel.name"
|
||||
class="name">{{ channel.name }}</span>
|
||||
<span v-if="channel.type === 'channel' && channel.state === 0">(parted)</span>
|
||||
<span
|
||||
v-if="channel.unread"
|
||||
:class="{ highlight: channel.highlight }"
|
||||
|
@ -5,7 +5,7 @@ const socket = require("../socket");
|
||||
const templates = require("../../views");
|
||||
const sidebar = $("#sidebar");
|
||||
const utils = require("../utils");
|
||||
const {vueApp, initChannel} = require("../vue");
|
||||
const {vueApp, initChannel, findChannel} = require("../vue");
|
||||
|
||||
socket.on("network", function(data) {
|
||||
const network = data.networks[0];
|
||||
@ -35,6 +35,18 @@ socket.on("network:status", function(data) {
|
||||
const network = vueApp.networks.find((n) => n.uuid === data.network);
|
||||
network.status.connected = data.connected;
|
||||
network.status.secure = data.secure;
|
||||
|
||||
if (!data.connected) {
|
||||
network.channels.forEach((channel) => channel.state = 0);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("channel:state", function(data) {
|
||||
const channel = findChannel(data.chan);
|
||||
|
||||
if (channel) {
|
||||
channel.channel.state = data.state;
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("network:info", function(data) {
|
||||
|
@ -29,6 +29,11 @@ module.exports = function(irc, network) {
|
||||
network.irc.raw("MODE", chan.name);
|
||||
} else if (data.nick === irc.user.nick) {
|
||||
chan.state = Chan.State.JOINED;
|
||||
|
||||
client.emit("channel:state", {
|
||||
chan: chan.id,
|
||||
state: chan.state,
|
||||
});
|
||||
}
|
||||
|
||||
const user = new User({nick: data.nick});
|
||||
|
@ -27,6 +27,11 @@ module.exports = function(irc, network) {
|
||||
if (data.kicked === irc.user.nick) {
|
||||
chan.users = new Map();
|
||||
chan.state = Chan.State.PARTED;
|
||||
|
||||
client.emit("channel:state", {
|
||||
chan: chan.id,
|
||||
state: chan.state,
|
||||
});
|
||||
} else {
|
||||
chan.removeUser(msg.target);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user