Fix old name prepopulate, run formatter

This commit is contained in:
Cohee
2024-10-09 01:29:23 +03:00
parent 4b0d342e8b
commit 7061753d84

View File

@@ -329,7 +329,7 @@ class PresetManager {
* @returns {any} Preset value
*/
findPreset(name) {
return $(this.select).find('option').filter(function() {
return $(this.select).find('option').filter(function () {
return $(this).text() === name;
}).val();
}
@@ -355,7 +355,7 @@ class PresetManager {
* @param {string} value Preset option value
*/
selectPreset(value) {
const option = $(this.select).filter(function() {
const option = $(this.select).filter(function () {
return $(this).val() === value;
});
option.prop('selected', true);
@@ -739,7 +739,8 @@ async function waitForConnection() {
export async function initPresetManager() {
eventSource.on(event_types.CHAT_CHANGED, autoSelectPreset);
registerPresetManagers();
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'preset',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'preset',
callback: presetCommandCallback,
returns: 'current preset',
unnamedArgumentList: [
@@ -802,9 +803,9 @@ export async function initPresetManager() {
}
const popupHeader = !presetManager.isAdvancedFormatting() ? t`Rename preset` : t`Rename template`;
const oldName = name;
const oldName = presetManager.getSelectedPresetName();
const newName = await Popup.show.input(popupHeader, t`Enter a new name:`, oldName);
if (oldName === newName || !newName) {
if (!newName || oldName === newName) {
console.debug(!presetManager.isAdvancedFormatting() ? 'Preset rename cancelled' : 'Template rename cancelled');
return;
}