fixed incorrect event handler binding

closes #3669
This commit is contained in:
Miodec 2022-10-19 00:30:23 +02:00
parent 293a7868e2
commit ebd19f0a56

View file

@ -119,29 +119,25 @@ $("#apeKeysPopup .generateApeKey").on("click", () => {
hide();
});
$("#popups #apeKeysPopup").on("click", "table .keyButtons .button", () => {
$("#popups").on("click", "#apeKeysPopup table .keyButtons .button", () => {
hide();
});
$("#popups #apeKeysPopup").on(
"click",
"#apeKeysPopup table .textButton",
async (e) => {
const keyId = $(e.target).closest("tr").attr("keyId") as string;
const key = apeKeys?.[keyId];
if (!key || !apeKeys) return;
Loader.show();
const response = await Ape.apeKeys.update(keyId, { enabled: !key.enabled });
Loader.hide();
if (response.status !== 200) {
return Notifications.add("Failed to update key: " + response.message, -1);
}
apeKeys[keyId].enabled = !key.enabled;
refreshList();
if (key.enabled) {
Notifications.add("Key active", 1);
} else {
Notifications.add("Key inactive", 1);
}
$("#popups").on("click", "#apeKeysPopup table .textButton", async (e) => {
const keyId = $(e.target).closest("tr").attr("keyId") as string;
const key = apeKeys?.[keyId];
if (!key || !apeKeys) return;
Loader.show();
const response = await Ape.apeKeys.update(keyId, { enabled: !key.enabled });
Loader.hide();
if (response.status !== 200) {
return Notifications.add("Failed to update key: " + response.message, -1);
}
);
apeKeys[keyId].enabled = !key.enabled;
refreshList();
if (key.enabled) {
Notifications.add("Key active", 1);
} else {
Notifications.add("Key inactive", 1);
}
});