fix: check API key before starting recording
Previously the API key was only validated after stopping the recording, wasting a full take if no key was configured. Now startRecording() checks the transcription provider's API key up front and aborts with a notice before touching the mic.
This commit is contained in:
@@ -89,6 +89,10 @@ export default class NibbleAI extends Plugin {
|
|||||||
new Notice("Already recording");
|
new Notice("Already recording");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!this.audioHandler.getTranscriptionApiKey()) {
|
||||||
|
new Notice("✘ Add your API key for the selected transcription provider in NibbleAI settings");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await this.recorder.startRecording();
|
await this.recorder.startRecording();
|
||||||
this.statusBar.updateStatus(RecordingStatus.Recording);
|
this.statusBar.updateStatus(RecordingStatus.Recording);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export class AudioHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTranscriptionApiKey(): string {
|
getTranscriptionApiKey(): string {
|
||||||
switch (this.plugin.settings.transcriptionProvider) {
|
switch (this.plugin.settings.transcriptionProvider) {
|
||||||
case "groq":
|
case "groq":
|
||||||
return this.plugin.settings.groqApiKey;
|
return this.plugin.settings.groqApiKey;
|
||||||
|
|||||||
Reference in New Issue
Block a user