Update translation extension to new popup

This commit is contained in:
Cohee 2024-06-26 00:40:13 +03:00
parent d188795591
commit 2ef6004bd5
1 changed files with 4 additions and 4 deletions

View File

@ -1,7 +1,6 @@
export { translate }; export { translate };
import { import {
callPopup,
eventSource, eventSource,
event_types, event_types,
getRequestHeaders, getRequestHeaders,
@ -11,6 +10,7 @@ import {
updateMessageBlock, updateMessageBlock,
} from '../../../script.js'; } from '../../../script.js';
import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js'; import { extension_settings, getContext, renderExtensionTemplateAsync } from '../../extensions.js';
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
import { findSecret, secret_state, writeSecret } from '../../secrets.js'; import { findSecret, secret_state, writeSecret } from '../../secrets.js';
import { SlashCommand } from '../../slash-commands/SlashCommand.js'; import { SlashCommand } from '../../slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js'; import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from '../../slash-commands/SlashCommandArgument.js';
@ -510,7 +510,7 @@ async function onTranslateChatClick() {
async function onTranslationsClearClick() { async function onTranslationsClearClick() {
const popupHtml = await renderExtensionTemplateAsync('translate', 'deleteConfirmation'); const popupHtml = await renderExtensionTemplateAsync('translate', 'deleteConfirmation');
const confirm = await callPopup(popupHtml, 'confirm'); const confirm = await callGenericPopup(popupHtml, POPUP_TYPE.CONFIRM);
if (!confirm) { if (!confirm) {
return; return;
@ -598,7 +598,7 @@ jQuery(async () => {
$(document).on('click', '.mes_translate', onMessageTranslateClick); $(document).on('click', '.mes_translate', onMessageTranslateClick);
$('#translate_key_button').on('click', async () => { $('#translate_key_button').on('click', async () => {
const optionText = $('#translation_provider option:selected').text(); const optionText = $('#translation_provider option:selected').text();
const key = await callPopup(`<h3>${optionText} API Key</h3>`, 'input'); const key = await callGenericPopup(`<h3>${optionText} API Key</h3>`, POPUP_TYPE.INPUT);
if (key == false) { if (key == false) {
return; return;
@ -621,7 +621,7 @@ jQuery(async () => {
const secretKey = extension_settings.translate.provider + '_url'; const secretKey = extension_settings.translate.provider + '_url';
const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : ''; const savedUrl = secret_state[secretKey] ? await findSecret(secretKey) : '';
const url = await callPopup(popupText, 'input', savedUrl); const url = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedUrl);
if (url == false || url == '') { if (url == false || url == '') {
return; return;