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