Fix incorrect target in (dis)connect context menu

This commit is contained in:
Pavel Djundik 2018-07-06 21:21:57 +03:00
parent d5f0a2481f
commit 9447b4894d

View File

@ -127,57 +127,35 @@ function addCloseItem() {
}
function addConnectItem() {
let clickedNetwork;
function isDisconnected(target) {
return target.parent().hasClass("not-connected");
}
function connect() {
function connect(itemData) {
socket.emit("input", {
target: $("#chat").data("id"),
target: Number(itemData),
text: "/connect",
});
}
function check(target) {
clickedNetwork = target;
return target.hasClass("lobby") && isDisconnected(target);
}
addContextMenuItem({
check: check,
check: (target) => target.hasClass("lobby") && target.parent().hasClass("not-connected"),
className: "connect",
displayName: "Connect",
data: () => clickedNetwork.data("id"),
data: (target) => target.data("id"),
callback: connect,
});
}
function addDisconnectItem() {
let clickedNetwork;
function isConnected(target) {
return !target.parent().hasClass("not-connected");
}
function disconnect() {
function disconnect(itemData) {
socket.emit("input", {
target: $("#chat").data("id"),
target: Number(itemData),
text: "/disconnect",
});
}
function check(target) {
clickedNetwork = target;
return target.hasClass("lobby") && isConnected(target);
}
addContextMenuItem({
check: check,
check: (target) => target.hasClass("lobby") && !target.parent().hasClass("not-connected"),
className: "disconnect",
displayName: "Disconnect",
data: () => clickedNetwork.data("id"),
data: (target) => target.data("id"),
callback: disconnect,
});
}