Update popup usage
| @@ -73,7 +73,7 @@ import { SlashCommand } from './slash-commands/SlashCommand.js'; | |||
| 73 | import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js'; | 73 | import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js'; |
| 74 | import { renderTemplateAsync } from './templates.js'; | 74 | import { renderTemplateAsync } from './templates.js'; |
| 75 | import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js'; | 75 | import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js'; |
| 76 | import { Popup, POPUP_RESULT, POPUP_TYPE, PopupUtils } from './popup.js'; | 76 | import { Popup, POPUP_RESULT } from './popup.js'; |
| 77 | 77 | ||
| 78 | export { | 78 | export { |
| 79 | openai_messages_count, | 79 | openai_messages_count, |
| @@ -3525,10 +3525,9 @@ async function onPresetImportFileChange(e) { | |||
| 3525 | if (shouldConfirm) { | 3525 | if (shouldConfirm) { |
| 3526 | const textHeader = 'The imported preset contains proxy and/or custom endpoint settings.'; | 3526 | const textHeader = 'The imported preset contains proxy and/or custom endpoint settings.'; |
| 3527 | const textMessage = fields.join('<br>'); | 3527 | const textMessage = fields.join('<br>'); |
| 3528 | const cancelButton = { text: 'Cancel import', result: POPUP_RESULT.CANCELLED, appendAtEnd: true, action: () => popup.complete(POPUP_RESULT.CANCELLED) }; | 3528 | const cancelButton = { text: 'Cancel import', result: POPUP_RESULT.CANCELLED, appendAtEnd: true }; |
| 3529 | const popupOptions = { customButtons: [cancelButton], okButton: 'Remove them', cancelButton: 'Import as-is' }; | 3529 | const popupOptions = { customButtons: [cancelButton], okButton: 'Remove them', cancelButton: 'Import as-is' }; |
| 3530 | const popup = new Popup(PopupUtils.BuildTextWithHeader(textHeader, textMessage), POPUP_TYPE.CONFIRM, '', popupOptions); | 3530 | const popupResult = await Popup.show.confirm(textHeader, textMessage, popupOptions); |
| 3531 | const popupResult = await popup.show(); | ||
| 3532 | 3531 | ||
| 3533 | if (popupResult === POPUP_RESULT.CANCELLED) { | 3532 | if (popupResult === POPUP_RESULT.CANCELLED) { |
| 3534 | console.log('Import cancelled by user'); | 3533 | console.log('Import cancelled by user'); |
| @@ -3590,10 +3589,9 @@ async function onExportPresetClick() { | |||
| 3590 | const shouldConfirm = fieldValues.length > 0; | 3589 | const shouldConfirm = fieldValues.length > 0; |
| 3591 | const textHeader = 'Your preset contains proxy and/or custom endpoint settings.'; | 3590 | const textHeader = 'Your preset contains proxy and/or custom endpoint settings.'; |
| 3592 | const textMessage = `<div>Do you want to remove these fields before exporting?</div><br>${DOMPurify.sanitize(fieldValues.join('<br>'))}`; | 3591 | const textMessage = `<div>Do you want to remove these fields before exporting?</div><br>${DOMPurify.sanitize(fieldValues.join('<br>'))}`; |
| 3593 | const cancelButton = { text: 'Cancel', result: POPUP_RESULT.CANCELLED, appendAtEnd: true, action: () => popup.complete(POPUP_RESULT.CANCELLED) }; | 3592 | const cancelButton = { text: 'Cancel', result: POPUP_RESULT.CANCELLED, appendAtEnd: true }; |
| 3594 | const popupOptions = { customButtons: [cancelButton] }; | 3593 | const popupOptions = { customButtons: [cancelButton] }; |
| 3595 | const popup = new Popup(PopupUtils.BuildTextWithHeader(textHeader, textMessage), POPUP_TYPE.CONFIRM, '', popupOptions); | 3594 | const popupResult = await Popup.show.confirm(textHeader, textMessage, popupOptions); |
| 3596 | const popupResult = shouldConfirm && await popup.show(); | ||
| 3597 | 3595 | ||
| 3598 | if (popupResult === POPUP_RESULT.CANCELLED) { | 3596 | if (popupResult === POPUP_RESULT.CANCELLED) { |
| 3599 | console.log('Export cancelled by user'); | 3597 | console.log('Export cancelled by user'); |
| @@ -565,7 +565,7 @@ export class Popup { | |||
| 565 | }; | 565 | }; |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 568 | export class PopupUtils { | 568 | class PopupUtils { |
| 569 | /** | 569 | /** |
| 570 | * Builds popup content with header and text below | 570 | * Builds popup content with header and text below |
| 571 | * | 571 | * |