mirror of
https://github.com/thelounge/thelounge
synced 2024-11-29 07:20:25 +00:00
dd05ee3a65
Co-authored-by: Eric Nemchik <eric@nemchik.com> Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
38 lines
759 B
TypeScript
38 lines
759 B
TypeScript
import eventbus from "../eventbus";
|
|
import socket from "../socket";
|
|
import {ClientChan} from "../types";
|
|
|
|
export default function useCloseChannel(channel: ClientChan) {
|
|
return () => {
|
|
if (channel.type === "lobby") {
|
|
eventbus.emit(
|
|
"confirm-dialog",
|
|
{
|
|
title: "Remove network",
|
|
text: `Are you sure you want to quit and remove ${channel.name}? This cannot be undone.`,
|
|
button: "Remove network",
|
|
},
|
|
(result: boolean) => {
|
|
if (!result) {
|
|
return;
|
|
}
|
|
|
|
channel.closed = true;
|
|
socket.emit("input", {
|
|
target: Number(channel.id),
|
|
text: "/quit",
|
|
});
|
|
}
|
|
);
|
|
|
|
return;
|
|
}
|
|
|
|
channel.closed = true;
|
|
|
|
socket.emit("input", {
|
|
target: Number(channel.id),
|
|
text: "/close",
|
|
});
|
|
};
|
|
}
|