Fix incorrect target in (dis)connect context menu
This commit is contained in:
parent
d5f0a2481f
commit
9447b4894d
@ -127,57 +127,35 @@ function addCloseItem() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addConnectItem() {
|
function addConnectItem() {
|
||||||
let clickedNetwork;
|
function connect(itemData) {
|
||||||
|
|
||||||
function isDisconnected(target) {
|
|
||||||
return target.parent().hasClass("not-connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
function connect() {
|
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
target: $("#chat").data("id"),
|
target: Number(itemData),
|
||||||
text: "/connect",
|
text: "/connect",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function check(target) {
|
|
||||||
clickedNetwork = target;
|
|
||||||
return target.hasClass("lobby") && isDisconnected(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
addContextMenuItem({
|
addContextMenuItem({
|
||||||
check: check,
|
check: (target) => target.hasClass("lobby") && target.parent().hasClass("not-connected"),
|
||||||
className: "connect",
|
className: "connect",
|
||||||
displayName: "Connect",
|
displayName: "Connect",
|
||||||
data: () => clickedNetwork.data("id"),
|
data: (target) => target.data("id"),
|
||||||
callback: connect,
|
callback: connect,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addDisconnectItem() {
|
function addDisconnectItem() {
|
||||||
let clickedNetwork;
|
function disconnect(itemData) {
|
||||||
|
|
||||||
function isConnected(target) {
|
|
||||||
return !target.parent().hasClass("not-connected");
|
|
||||||
}
|
|
||||||
|
|
||||||
function disconnect() {
|
|
||||||
socket.emit("input", {
|
socket.emit("input", {
|
||||||
target: $("#chat").data("id"),
|
target: Number(itemData),
|
||||||
text: "/disconnect",
|
text: "/disconnect",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function check(target) {
|
|
||||||
clickedNetwork = target;
|
|
||||||
return target.hasClass("lobby") && isConnected(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
addContextMenuItem({
|
addContextMenuItem({
|
||||||
check: check,
|
check: (target) => target.hasClass("lobby") && !target.parent().hasClass("not-connected"),
|
||||||
className: "disconnect",
|
className: "disconnect",
|
||||||
displayName: "Disconnect",
|
displayName: "Disconnect",
|
||||||
data: () => clickedNetwork.data("id"),
|
data: (target) => target.data("id"),
|
||||||
callback: disconnect,
|
callback: disconnect,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user