Fix deleting template making a call on empty template list
This commit is contained in:
parent
99eea16f62
commit
b8707bbc9a
@ -872,23 +872,25 @@ $loadTemplateBtn.addEventListener("click", (ev) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$deleteTemplateBtn.addEventListener("click", (ev) => {
|
$deleteTemplateBtn.addEventListener("click", (ev) => {
|
||||||
fetch(`/dashboard/api/guild/${guildId()}/templates`, {
|
if (parseInt($templateSelect.value) !== null) {
|
||||||
method: "DELETE",
|
fetch(`/dashboard/api/guild/${guildId()}/templates`, {
|
||||||
headers: {
|
method: "DELETE",
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
},
|
"Content-Type": "application/json",
|
||||||
body: JSON.stringify({ id: parseInt($templateSelect.value) }),
|
},
|
||||||
})
|
body: JSON.stringify({ id: parseInt($templateSelect.value) }),
|
||||||
.then((response) => response.json())
|
})
|
||||||
.then((data) => {
|
.then((response) => response.json())
|
||||||
if (data.error) {
|
.then((data) => {
|
||||||
show_error(data.error);
|
if (data.error) {
|
||||||
} else {
|
show_error(data.error);
|
||||||
$templateSelect
|
} else {
|
||||||
.querySelector(`option[value="${$templateSelect.value}"]`)
|
$templateSelect
|
||||||
.remove();
|
.querySelector(`option[value="${$templateSelect.value}"]`)
|
||||||
}
|
.remove();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let $img;
|
let $img;
|
||||||
|
Loading…
Reference in New Issue
Block a user