From 307a579f80202712cd76501927699ecd6ebd2910 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 11 Jul 2024 01:37:56 +0200 Subject: [PATCH 1/4] Move preset manager popups to new Popup --- public/scripts/preset-manager.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 90fe232ba..0176937b0 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -1,6 +1,5 @@ import { amount_gen, - callPopup, characters, eventSource, event_types, @@ -19,6 +18,7 @@ import { import { groups, selected_group } from './group-chats.js'; import { instruct_presets } from './instruct-mode.js'; import { kai_settings } from './kai-settings.js'; +import { Popup } from './popup.js'; import { context_presets, getContextSettings, power_user } from './power-user.js'; import { SlashCommand } from './slash-commands/SlashCommand.js'; import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js'; @@ -165,11 +165,8 @@ class PresetManager { async savePresetAs() { const inputValue = this.getSelectedPresetName(); - const popupText = ` -

Preset name:

- ${!this.isNonGenericApi() ? '

Hint: Use a character/group name to bind preset to a specific chat.

' : ''}`; - const name = await callPopup(popupText, 'input', inputValue); - + const popupText = !this.isNonGenericApi() ? '

Hint: Use a character/group name to bind preset to a specific chat.

' : ''; + const name = Popup.show.input('Preset name:', popupText, inputValue); if (!name) { console.log('Preset name not provided'); return; @@ -597,8 +594,7 @@ export async function initPresetManager() { return; } - const confirm = await callPopup('Delete the preset? This action is irreversible and your current settings will be overwritten.', 'confirm'); - + const confirm = await Popup.show.input('Delete the preset?', 'This action is irreversible and your current settings will be overwritten.'); if (!confirm) { return; } @@ -641,8 +637,7 @@ export async function initPresetManager() { return; } - const confirm = await callPopup('

Are you sure?

Resetting a default preset will restore the default settings.', 'confirm'); - + const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a default preset will restore the default settings.'); if (!confirm) { return; } @@ -653,8 +648,7 @@ export async function initPresetManager() { presetManager.selectPreset(option); toastr.success('Default preset restored'); } else { - const confirm = await callPopup('

Are you sure?

Resetting a custom preset will restore to the last saved state.', 'confirm'); - + const confirm = await Popup.show.confirm('Are you sure?', 'Resetting a custom preset will restore to the last saved state.'); if (!confirm) { return; } From 3983eef8279ad461e8841e1df7301598194708bd Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Thu, 11 Jul 2024 01:38:28 +0200 Subject: [PATCH 2/4] fix linting issue --- public/scripts/preset-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 0176937b0..19c3f0bbd 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -369,7 +369,7 @@ class PresetManager { if (Object.keys(preset_names).length) { const nextPresetName = Object.keys(preset_names)[0]; const newValue = preset_names[nextPresetName]; - $(this.select).find(`option[value="${newValue}"]`).attr('selected', true); + $(this.select).find(`option[value="${newValue}"]`).attr('selected', 'true'); $(this.select).trigger('change'); } From f53fa0d19da20fd98ed5c8f7aaf1ce8ad343b86f Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:09:46 +0300 Subject: [PATCH 3/4] Add missing await --- public/scripts/preset-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 19c3f0bbd..756c518ef 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -166,7 +166,7 @@ class PresetManager { async savePresetAs() { const inputValue = this.getSelectedPresetName(); const popupText = !this.isNonGenericApi() ? '

Hint: Use a character/group name to bind preset to a specific chat.

' : ''; - const name = Popup.show.input('Preset name:', popupText, inputValue); + const name = await Popup.show.input('Preset name:', popupText, inputValue); if (!name) { console.log('Preset name not provided'); return; From f74c212945a8cf25a03d0945841e57b8d20997b5 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 12 Jul 2024 01:12:25 +0300 Subject: [PATCH 4/4] Fix popup type --- public/scripts/preset-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index 756c518ef..5d25140dc 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -594,7 +594,7 @@ export async function initPresetManager() { return; } - const confirm = await Popup.show.input('Delete the preset?', 'This action is irreversible and your current settings will be overwritten.'); + const confirm = await Popup.show.confirm('Delete the preset?', 'This action is irreversible and your current settings will be overwritten.'); if (!confirm) { return; }