thelounge/client/js/socket-events/join.js
Pavel Djundik 2f635069e0 Move vuex state to a separate file and reorganize some code
Co-Authored-By: Tim Miller-Williams <timmw@users.noreply.github.com>
2019-11-25 20:12:54 +02:00

24 lines
511 B
JavaScript

"use strict";
const socket = require("../socket");
const {vueApp, initChannel, findNetwork} = require("../vue");
socket.on("join", function(data) {
initChannel(data.chan);
const network = findNetwork(data.network);
if (!network) {
return;
}
network.channels.splice(data.index || -1, 0, data.chan);
// Queries do not automatically focus, unless the user did a whois
if (data.chan.type === "query" && !data.shouldOpen) {
return;
}
vueApp.switchToChannel(vueApp.findChannel(data.chan.id));
});