Always poll status after start/stop, even on API error
When apiPost throws (e.g. 400 "Already transcribing"), pollStatus never ran because it was in the try block. The button stayed stuck on "Start" even though transcription was running. Moved pollStatus to the finally block so it always syncs the UI with actual backend state. Also suppresses the error message for 400 responses since they just mean the state is already correct. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,14 +20,17 @@
|
||||
} else {
|
||||
await backendStore.apiPost("/api/start");
|
||||
}
|
||||
// Poll status to update UI immediately instead of waiting
|
||||
// for WebSocket broadcast (which can be delayed or missed)
|
||||
await backendStore.pollStatus();
|
||||
} catch (err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
// Ignore "Already transcribing/not transcribing" -- just sync the state
|
||||
if (!msg.includes("400")) {
|
||||
console.error("Failed to toggle transcription:", msg);
|
||||
errorMessage = msg;
|
||||
}
|
||||
} finally {
|
||||
// Always poll status to sync UI with actual backend state,
|
||||
// even if the API call failed (e.g. "Already transcribing")
|
||||
await backendStore.pollStatus();
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user