thelounge/client/js/socket-events/quit.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

22 lines
639 B
TypeScript

import socket from "../socket";
import {switchToChannel, navigate} from "../router";
import {store} from "../store";
socket.on("quit", async 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;
}
if (store.state.networks.length > 0) {
switchToChannel(store.state.networks[0].channels[0]);
} else {
await navigate("Connect");
}
});