mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Refactor prepare/redraw for consistency
This commit is contained in:
@ -317,15 +317,7 @@ export class SettingsUi {
|
|||||||
this.currentQrSet.name = newName;
|
this.currentQrSet.name = newName;
|
||||||
await this.currentQrSet.save();
|
await this.currentQrSet.save();
|
||||||
|
|
||||||
// Update the option in all select dropdowns
|
// Update it in both set lists
|
||||||
/** @type {NodeListOf<HTMLOptionElement>} */
|
|
||||||
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
|
|
||||||
this.settings.config.setList.forEach(set => {
|
this.settings.config.setList.forEach(set => {
|
||||||
if (set.set.name === oldName) {
|
if (set.set.name === oldName) {
|
||||||
set.set.name = newName;
|
set.set.name = newName;
|
||||||
@ -336,9 +328,19 @@ export class SettingsUi {
|
|||||||
set.set.name = newName;
|
set.set.name = newName;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.settings.save();
|
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.currentSet.value = newName;
|
||||||
|
this.onQrSetChange();
|
||||||
|
this.prepareGlobalSetList();
|
||||||
|
this.prepareChatSetList();
|
||||||
|
|
||||||
console.info(`Quick Reply Set renamed from ""${oldName}" to "${newName}".`);
|
console.info(`Quick Reply Set renamed from ""${oldName}" to "${newName}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user