From b89d41a70145bcf1ca6dc47d3dd00a21667b3ffe Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sat, 11 Jan 2025 02:31:14 +0100 Subject: [PATCH] Refactor prepare/redraw for consistency --- .../quick-reply/src/ui/SettingsUi.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js b/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js index 419275b92..df6bb081f 100644 --- a/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js +++ b/public/scripts/extensions/quick-reply/src/ui/SettingsUi.js @@ -317,15 +317,7 @@ export class SettingsUi { this.currentQrSet.name = newName; await this.currentQrSet.save(); - // Update the option in all select dropdowns - /** @type {NodeListOf} */ - const options = this.dom.querySelectorAll(`#qr--set option[value="${oldName}"], select.qr--set option[value="${oldName}"]`); - options.forEach(option => { - option.value = newName; - option.textContent = newName; - }); - - // Update in in both set lists + // Update it in both set lists this.settings.config.setList.forEach(set => { if (set.set.name === oldName) { set.set.name = newName; @@ -336,9 +328,19 @@ export class SettingsUi { set.set.name = newName; } }); - this.settings.save(); + + // Update the option in the current selected QR dropdown. All others will be refreshed via the prepare calls below. + /** @type {HTMLOptionElement} */ + const option = this.currentSet.querySelector(`#qr--set option[value="${oldName}"]`); + option.value = newName; + option.textContent = newName; + this.currentSet.value = newName; + this.onQrSetChange(); + this.prepareGlobalSetList(); + this.prepareChatSetList(); + console.info(`Quick Reply Set renamed from ""${oldName}" to "${newName}".`); } }