Confirm custom PM prompt deletion
| @@ -1,12 +1,13 @@ | |||
| 1 | 'use strict'; | 1 | 'use strict'; |
| 2 | 2 | ||
| 3 | import { callPopup, event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js'; | 3 | import { event_types, eventSource, is_send_press, main_api, substituteParams } from '../script.js'; |
| 4 | import { is_group_generating } from './group-chats.js'; | 4 | import { is_group_generating } from './group-chats.js'; |
| 5 | import { Message, TokenHandler } from './openai.js'; | 5 | import { Message, TokenHandler } from './openai.js'; |
| 6 | import { power_user } from './power-user.js'; | 6 | import { power_user } from './power-user.js'; |
| 7 | import { debounce, waitUntilCondition, escapeHtml } from './utils.js'; | 7 | import { debounce, waitUntilCondition, escapeHtml } from './utils.js'; |
| 8 | import { debounce_timeout } from './constants.js'; | 8 | import { debounce_timeout } from './constants.js'; |
| 9 | import { renderTemplateAsync } from './templates.js'; | 9 | import { renderTemplateAsync } from './templates.js'; |
| 10 | import { Popup } from './popup.js'; | ||
| 10 | 11 | ||
| 11 | function debouncePromise(func, delay) { | 12 | function debouncePromise(func, delay) { |
| 12 | let timeoutId; | 13 | let timeoutId; |
| @@ -453,7 +454,9 @@ class PromptManager { | |||
| 453 | }; | 454 | }; |
| 454 | 455 | ||
| 455 | // Delete selected prompt from list form and close edit form | 456 | // 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); |
| 459 | 462 | ||
| @@ -468,6 +471,7 @@ class PromptManager { | |||
| 468 | this.render(); | 471 | this.render(); |
| 469 | this.saveServiceSettings(); | 472 | this.saveServiceSettings(); |
| 470 | } | 473 | } |
| 474 | }); | ||
| 471 | }; | 475 | }; |
| 472 | 476 | ||
| 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 { | |||
| 527 | 531 | ||
| 528 | // Import prompts for the selected character | 532 | // 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; |
| 533 | 537 | ||
| 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 { | |||
| 563 | 567 | ||
| 564 | // Restore default state of a characters prompt order | 568 | // 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; |
| 569 | 573 | ||
| 570 | this.removePromptOrderForCharacter(this.activeCharacter); | 574 | this.removePromptOrderForCharacter(this.activeCharacter); |
| 571 | this.addPromptOrderForCharacter(this.activeCharacter, promptManagerDefaultPromptOrder); | 575 | this.addPromptOrderForCharacter(this.activeCharacter, promptManagerDefaultPromptOrder); |