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 @@
11'use strict';
22
33import { callPopup, event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js';
44import { is_group_generating } from './group-chats.js';
55import { Message, TokenHandler } from './openai.js';
66import { power_user } from './power-user.js';
77import { debounce, waitUntilCondition, escapeHtml } from './utils.js';
88import { debounce_timeout } from './constants.js';
99import { renderTemplateAsync } from './templates.js';
10+import { Popup } from './popup.js';
1011
1112function debouncePromise(func, delay) {
1213 let timeoutId;
@@ -453,7 +454,9 @@ class PromptManager {
453454 };
454455
455456 // Delete selected prompt from list form and close edit form
456457 this.handleDeletePrompt = async (event) => {
458+ Popup.show.confirm('Are you sure you want to delete this prompt?', null).then((userChoice) => {
459+ if (!userChoice) return;
457460 const promptID = document.getElementById(this.configuration.prefix + 'prompt_manager_footer_append_prompt').value;
458461 const prompt = this.getPromptById(promptID);
459462
@@ -468,6 +471,7 @@ class PromptManager {
468471 this.render();
469472 this.saveServiceSettings();
470473 }
474+ });
471475 };
472476
473477 // Create new prompt, then save it to settings and close form.
@@ -527,9 +531,9 @@ class PromptManager {
527531
528532 // Import prompts for the selected character
529533 this.handleImport = () => {
530534 callPopupPopup.show.confirm('Existing prompts with the same ID will be overridden. Do you want to proceed?', 'confirm'null)
531535 .then(userChoice => {
532536 if (false === !userChoice) return;
533537
534538 const fileOpener = document.createElement('input');
535539 fileOpener.type = 'file';
@@ -563,9 +567,9 @@ class PromptManager {
563567
564568 // Restore default state of a characters prompt order
565569 this.handleCharacterReset = () => {
566570 callPopupPopup.show.confirm('This will reset the prompt order for this character. You will not lose any prompts.', 'confirm'null)
567571 .then(userChoice => {
568572 if (false === !userChoice) return;
569573
570574 this.removePromptOrderForCharacter(this.activeCharacter);
571575 this.addPromptOrderForCharacter(this.activeCharacter, promptManagerDefaultPromptOrder);