Fix translation key removal

01b83f893bcfb474ef9f01d36a68c3289603645b

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

1 files changed, +14 -3Showing whitespace changes
public/scripts/extensions/translate/index.js+14 -3
@@ -598,9 +598,20 @@ jQuery(async () => {
598598 $(document).on('click', '.mes_translate', onMessageTranslateClick);
599599 $('#translate_key_button').on('click', async () => {
600600 const optionText = $('#translation_provider option:selected').text();
601601 const key = await callGenericPopup(`<h3>${optionText} API Key</h3>`, POPUP_TYPE.INPUT);, '', {
602+ customButtons: [{
603+ text: 'Remove Key',
604+ appendAtEnd: true,
605+ result: POPUP_RESULT.NEGATIVE,
606+ action: async () => {
607+ await writeSecret(extension_settings.translate.provider, '');
608+ toastr.success('API Key removed');
609+ $('#translate_key_button').toggleClass('success', !!secret_state[extension_settings.translate.provider]);
610+ },
611+ }],
612+ });
602613
603614 if (!key == false) {
604615 return;
605616 }
606617
@@ -634,7 +645,7 @@ jQuery(async () => {
634645 }],
635646 });
636647
637- if (url == false || url == '') {
648+ if (!url) {
638649 return;
639650 }
640651