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) => {
|
||||
fetch(`/dashboard/api/guild/${guildId()}/templates`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ id: parseInt($templateSelect.value) }),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data.error) {
|
||||
show_error(data.error);
|
||||
} else {
|
||||
$templateSelect
|
||||
.querySelector(`option[value="${$templateSelect.value}"]`)
|
||||
.remove();
|
||||
}
|
||||
});
|
||||
if (parseInt($templateSelect.value) !== null) {
|
||||
fetch(`/dashboard/api/guild/${guildId()}/templates`, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ id: parseInt($templateSelect.value) }),
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (data.error) {
|
||||
show_error(data.error);
|
||||
} else {
|
||||
$templateSelect
|
||||
.querySelector(`option[value="${$templateSelect.value}"]`)
|
||||
.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let $img;
|
||||
|
Loading…
Reference in New Issue
Block a user