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) {
|
2019-11-11 12:19:03 +00:00
|
|
|
// 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;
|
|
|
|
|
2019-11-02 19:40:59 +00:00
|
|
|
store.commit("removeNetwork", data.network);
|
2018-07-06 18:15:15 +00:00
|
|
|
|
2019-11-11 12:19:03 +00:00
|
|
|
if (!isCurrentNetworkBeingRemoved) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-12 12:52:16 +00:00
|
|
|
|
2019-11-11 12:19:03 +00:00
|
|
|
if (store.state.networks.length > 0) {
|
2019-11-11 19:18:55 +00:00
|
|
|
switchToChannel(store.state.networks[0].channels[0]);
|
2019-11-11 12:19:03 +00:00
|
|
|
} else {
|
2019-11-11 19:18:55 +00:00
|
|
|
navigate("Connect");
|
2019-11-11 12:19:03 +00:00
|
|
|
}
|
2017-05-18 20:08:54 +00:00
|
|
|
});
|