Partially fix reminder usernames resetting

This commit is contained in:
jude 2023-08-07 21:50:11 +01:00
parent 6a94f990cf
commit 77f17c8dc2

View File

@ -66,19 +66,30 @@ function update_select(sel) {
return; return;
} }
if (sel.selectedOptions[0].dataset["webhookAvatar"]) { let isCreating = sel.closest("div.reminderContent").classList.contains("creator");
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src =
sel.selectedOptions[0].dataset["webhookAvatar"]; if (!isCreating) {
} else { return;
sel.closest("div.reminderContent").querySelector("img.discord-avatar").src =
"/static/img/icon.png";
} }
if (sel.selectedOptions[0].dataset["webhookName"]) {
sel.closest("div.reminderContent").querySelector("input.discord-username").value = const avatarInput = sel
sel.selectedOptions[0].dataset["webhookName"]; .closest("div.reminderContent")
.querySelector("img.discord-avatar");
if (sel.selectedOptions[0].dataset["webhookAvatar"]) {
avatarInput.src = sel.selectedOptions[0].dataset["webhookAvatar"];
} else { } else {
sel.closest("div.reminderContent").querySelector("input.discord-username").value = avatarInput.src = "/static/img/icon.png";
"Reminder"; }
const usernameInput = sel
.closest("div.reminderContent")
.querySelector("input.discord-username");
if (sel.selectedOptions[0].dataset["webhookName"]) {
usernameInput.value = sel.selectedOptions[0].dataset["webhookName"];
} else {
usernameInput.value = "Reminder";
} }
} }