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

25 lines
640 B
JavaScript
Raw Normal View History

2017-05-18 22:08:54 +02:00
"use strict";
2019-11-16 18:24:03 +01:00
import socket from "../socket";
import {switchToChannel, navigate} from "../router";
import store from "../store";
2017-05-18 22:08:54 +02: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 14:52:16 +02:00
if (store.state.networks.length > 0) {
2019-11-11 20:18:55 +01:00
switchToChannel(store.state.networks[0].channels[0]);
} else {
2019-11-11 20:18:55 +01:00
navigate("Connect");
}
2017-05-18 22:08:54 +02:00
});