Refactor prepare/redraw for consistency
| @@ -317,15 +317,7 @@ export class SettingsUi { | ||
| 317 | 317 | this.currentQrSet.name = newName; |
| 318 | 318 | await this.currentQrSet.save(); |
| 319 | 319 | |
| 320 | 320 | // Update the optionit in allboth selectset dropdownslists |
| 321 | - /** @type {NodeListOf<HTMLOptionElement>} */ | |
| 322 | - const options = this.dom.querySelectorAll(`#qr--set option[value="${oldName}"], select.qr--set option[value="${oldName}"]`); | |
| 323 | - options.forEach(option => { | |
| 324 | - option.value = newName; | |
| 325 | - option.textContent = newName; | |
| 326 | - }); | |
| 327 | - | |
| 328 | - // Update in in both set lists | |
| 329 | 321 | this.settings.config.setList.forEach(set => { |
| 330 | 322 | if (set.set.name === oldName) { |
| 331 | 323 | set.set.name = newName; |
| @@ -336,9 +328,19 @@ export class SettingsUi { | ||
| 336 | 328 | set.set.name = newName; |
| 337 | 329 | } |
| 338 | 330 | }); |
| 339 | - | |
| 340 | 331 | this.settings.save(); |
| 332 | + | |
| 333 | + // Update the option in the current selected QR dropdown. All others will be refreshed via the prepare calls below. | |
| 334 | + /** @type {HTMLOptionElement} */ | |
| 335 | + const option = this.currentSet.querySelector(`#qr--set option[value="${oldName}"]`); | |
| 336 | + option.value = newName; | |
| 337 | + option.textContent = newName; | |
| 338 | + | |
| 341 | 339 | this.currentSet.value = newName; |
| 340 | + this.onQrSetChange(); | |
| 341 | + this.prepareGlobalSetList(); | |
| 342 | + this.prepareChatSetList(); | |
| 343 | + | |
| 342 | 344 | console.info(`Quick Reply Set renamed from ""${oldName}" to "${newName}".`); |
| 343 | 345 | } |
| 344 | 346 | } |