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

@@ -739,7 +739,8 @@ async function waitForConnection() {
export async function initPresetManager() { export async function initPresetManager() {
eventSource.on(event_types.CHAT_CHANGED, autoSelectPreset); eventSource.on(event_types.CHAT_CHANGED, autoSelectPreset);
registerPresetManagers(); registerPresetManagers();
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'preset', SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'preset',
callback: presetCommandCallback, callback: presetCommandCallback,
returns: 'current preset', returns: 'current preset',
unnamedArgumentList: [ unnamedArgumentList: [
@@ -802,9 +803,9 @@ export async function initPresetManager() {
} }
const popupHeader = !presetManager.isAdvancedFormatting() ? t`Rename preset` : t`Rename template`; 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); 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'); console.debug(!presetManager.isAdvancedFormatting() ? 'Preset rename cancelled' : 'Template rename cancelled');
return; return;
} }