Update popup usage

3a0b4ec41dcd48eea8db92b6ee28e4b3c9495e46

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

2 files changed, +6 -8Showing whitespace changes
public/scripts/openai.js+5 -7
@@ -73,7 +73,7 @@ import { SlashCommand } from './slash-commands/SlashCommand.js';
73import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js';73import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashCommandArgument.js';
74import { renderTemplateAsync } from './templates.js';74import { renderTemplateAsync } from './templates.js';
75import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js';75import { SlashCommandEnumValue } from './slash-commands/SlashCommandEnumValue.js';
76import { Popup, POPUP_RESULT, POPUP_TYPE, PopupUtils } from './popup.js';76import { Popup, POPUP_RESULT } from './popup.js';
7777
78export {78export {
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();
35323531
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();
35973595
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');
public/scripts/popup.js+1 -1
@@ -565,7 +565,7 @@ export class Popup {
565 };565 };
566}566}
567567
568export class PopupUtils {568class PopupUtils {
569 /**569 /**
570 * Builds popup content with header and text below570 * Builds popup content with header and text below
571 *571 *