From 01b83f893bcfb474ef9f01d36a68c3289603645b Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Fri, 13 Sep 2024 21:48:35 +0300 Subject: [PATCH] Fix translation key removal --- public/scripts/extensions/translate/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/public/scripts/extensions/translate/index.js b/public/scripts/extensions/translate/index.js index e170795ee..c58ef9f08 100644 --- a/public/scripts/extensions/translate/index.js +++ b/public/scripts/extensions/translate/index.js @@ -598,9 +598,20 @@ jQuery(async () => { $(document).on('click', '.mes_translate', onMessageTranslateClick); $('#translate_key_button').on('click', async () => { const optionText = $('#translation_provider option:selected').text(); - const key = await callGenericPopup(`

${optionText} API Key

`, POPUP_TYPE.INPUT); + const key = await callGenericPopup(`

${optionText} API Key

`, POPUP_TYPE.INPUT, '', { + customButtons: [{ + text: 'Remove Key', + appendAtEnd: true, + result: POPUP_RESULT.NEGATIVE, + action: async () => { + await writeSecret(extension_settings.translate.provider, ''); + toastr.success('API Key removed'); + $('#translate_key_button').toggleClass('success', !!secret_state[extension_settings.translate.provider]); + }, + }], + }); - if (key == false) { + if (!key) { return; } @@ -634,7 +645,7 @@ jQuery(async () => { }], }); - if (url == false || url == '') { + if (!url) { return; }