Confirm custom PM prompt deletion

a408328fc666b692858ddf1d3e460d4427027b82

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +10 -6Showing whitespace changes
public/scripts/PromptManager.js+10 -6
@@ -1,12 +1,13 @@
1'use strict';1'use strict';
22
3import { callPopup, event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js';3import { event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js';
4import { is_group_generating } from './group-chats.js';4import { is_group_generating } from './group-chats.js';
5import { Message, TokenHandler } from './openai.js';5import { Message, TokenHandler } from './openai.js';
6import { power_user } from './power-user.js';6import { power_user } from './power-user.js';
7import { debounce, waitUntilCondition, escapeHtml } from './utils.js';7import { debounce, waitUntilCondition, escapeHtml } from './utils.js';
8import { debounce_timeout } from './constants.js';8import { debounce_timeout } from './constants.js';
9import { renderTemplateAsync } from './templates.js';9import { renderTemplateAsync } from './templates.js';
10import { Popup } from './popup.js';
1011
11function debouncePromise(func, delay) {12function debouncePromise(func, delay) {
12 let timeoutId;13 let timeoutId;
@@ -453,7 +454,9 @@ class PromptManager {
453 };454 };
454455
455 // Delete selected prompt from list form and close edit form456 // Delete selected prompt from list form and close edit form
456 this.handleDeletePrompt = (event) => {457 this.handleDeletePrompt = async (event) => {
458 Popup.show.confirm('Are you sure you want to delete this prompt?', null).then((userChoice) => {
459 if (!userChoice) return;
457 const promptID = document.getElementById(this.configuration.prefix + 'prompt_manager_footer_append_prompt').value;460 const promptID = document.getElementById(this.configuration.prefix + 'prompt_manager_footer_append_prompt').value;
458 const prompt = this.getPromptById(promptID);461 const prompt = this.getPromptById(promptID);
459462
@@ -468,6 +471,7 @@ class PromptManager {
468 this.render();471 this.render();
469 this.saveServiceSettings();472 this.saveServiceSettings();
470 }473 }
474 });
471 };475 };
472476
473 // Create new prompt, then save it to settings and close form.477 // Create new prompt, then save it to settings and close form.
@@ -527,9 +531,9 @@ class PromptManager {
527531
528 // Import prompts for the selected character532 // Import prompts for the selected character
529 this.handleImport = () => {533 this.handleImport = () => {
530 callPopup('Existing prompts with the same ID will be overridden. Do you want to proceed?', 'confirm')534 Popup.show.confirm('Existing prompts with the same ID will be overridden. Do you want to proceed?', null)
531 .then(userChoice => {535 .then(userChoice => {
532 if (false === userChoice) return;536 if (!userChoice) return;
533537
534 const fileOpener = document.createElement('input');538 const fileOpener = document.createElement('input');
535 fileOpener.type = 'file';539 fileOpener.type = 'file';
@@ -563,9 +567,9 @@ class PromptManager {
563567
564 // Restore default state of a characters prompt order568 // Restore default state of a characters prompt order
565 this.handleCharacterReset = () => {569 this.handleCharacterReset = () => {
566 callPopup('This will reset the prompt order for this character. You will not lose any prompts.', 'confirm')570 Popup.show.confirm('This will reset the prompt order for this character. You will not lose any prompts.', null)
567 .then(userChoice => {571 .then(userChoice => {
568 if (false === userChoice) return;572 if (!userChoice) return;
569573
570 this.removePromptOrderForCharacter(this.activeCharacter);574 this.removePromptOrderForCharacter(this.activeCharacter);
571 this.addPromptOrderForCharacter(this.activeCharacter, promptManagerDefaultPromptOrder);575 this.addPromptOrderForCharacter(this.activeCharacter, promptManagerDefaultPromptOrder);