Fix saving presets after deletion of the same name

This commit is contained in:
Cohee 2023-12-17 21:02:32 +02:00
parent d629d96d05
commit a91f0f7ee5
1 changed files with 4 additions and 2 deletions

View File

@ -323,7 +323,7 @@ class PresetManager {
}
async deleteCurrentPreset() {
const { preset_names } = this.getPresetList();
const { preset_names, presets } = this.getPresetList();
const value = this.getSelectedPreset();
const nameToDelete = this.getSelectedPresetName();
@ -335,7 +335,9 @@ class PresetManager {
$(this.select).find(`option[value="${value}"]`).remove();
if (this.isKeyedApi()) {
preset_names.splice(preset_names.indexOf(value), 1);
const index = preset_names.indexOf(nameToDelete);
preset_names.splice(index, 1);
presets.splice(index, 1);
} else {
delete preset_names[nameToDelete];
}