Add remove key button for Azure TTS

This commit is contained in:
Cohee 2024-08-13 20:33:59 +03:00
parent 1883095e39
commit f17df7d9ad
2 changed files with 16 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import { getRequestHeaders } from '../../../script.js';
import { POPUP_TYPE, callGenericPopup } from '../../popup.js';
import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from '../../popup.js';
import { SECRET_KEYS, findSecret, secret_state, writeSecret } from '../../secrets.js';
import { getPreviewString, saveTtsProviderSettings } from './index.js';
export { AzureTtsProvider };
@ -70,7 +70,19 @@ class AzureTtsProvider {
const popupText = 'Azure TTS API Key';
const savedKey = secret_state[SECRET_KEYS.AZURE_TTS] ? await findSecret(SECRET_KEYS.AZURE_TTS) : '';
const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedKey);
const key = await callGenericPopup(popupText, POPUP_TYPE.INPUT, savedKey, {
customButtons: [{
text: 'Remove Key',
appendAtEnd: true,
result: POPUP_RESULT.NEGATIVE,
action: async () => {
await writeSecret(SECRET_KEYS.AZURE_TTS, '');
$('#azure_tts_key').toggleClass('success', secret_state[SECRET_KEYS.AZURE_TTS]);
toastr.success('API Key removed');
await this.onRefreshClick();
},
}],
});
if (key == false || key == '') {
return;

View File

@ -83,7 +83,7 @@ class OpenAICompatibleTtsProvider {
customButtons: [{
text: 'Remove Key',
appendAtEnd: true,
result: POPUP_RESULT.CANCELLED,
result: POPUP_RESULT.NEGATIVE,
action: async () => {
await writeSecret(SECRET_KEYS.CUSTOM_OPENAI_TTS, '');
$('#openai_compatible_tts_key').toggleClass('success', secret_state[SECRET_KEYS.CUSTOM_OPENAI_TTS]);
@ -93,7 +93,7 @@ class OpenAICompatibleTtsProvider {
}],
});
if (key == false || key == '' || key == null) {
if (key == false || key == '') {
return;
}