thelounge/client/js/socket-events/quit.js

25 lines
639 B
JavaScript
Raw Normal View History

2017-05-18 20:08:54 +00:00
"use strict";
2019-11-16 17:24:03 +00:00
import socket from "../socket";
import {switchToChannel, navigate} from "../router";
import store from "../store";
2017-05-18 20:08:54 +00:00
socket.on("quit", function(data) {
// If we're in a channel, and it's on the network that is being removed,
// then open another channel window
const isCurrentNetworkBeingRemoved =
store.state.activeChannel && store.state.activeChannel.network.uuid === data.network;
store.commit("removeNetwork", data.network);
if (!isCurrentNetworkBeingRemoved) {
return;
}
2017-09-12 12:52:16 +00:00
if (store.state.networks.length > 0) {
2019-11-11 19:18:55 +00:00
switchToChannel(store.state.networks[0].channels[0]);
} else {
2019-11-11 19:18:55 +00:00
navigate("Connect");
}
2017-05-18 20:08:54 +00:00
});