file upload real-time state management fix

This commit is contained in:
Igor Loskutov
2025-09-04 14:13:49 -04:00
parent 0751d01f13
commit ad780551b7
3 changed files with 35 additions and 7 deletions

View File

@@ -24,10 +24,16 @@ const TranscriptUpload = (details: TranscriptUpload) => {
const router = useRouter();
const [status, setStatus] = useState(
const [status_, setStatus] = useState(
webSockets.status.value || transcript.response?.status || "idle",
);
// status is obviously done if we have transcript
const status =
!transcript.loading && transcript.response?.status === "ended"
? transcript.response?.status
: status_;
useEffect(() => {
if (!transcriptStarted && webSockets.transcriptTextLive.length !== 0)
setTranscriptStarted(true);
@@ -35,8 +41,11 @@ const TranscriptUpload = (details: TranscriptUpload) => {
useEffect(() => {
//TODO HANDLE ERROR STATUS BETTER
// TODO deprecate webSockets.status.value / depend on transcript.response?.status from query lib
const newStatus =
webSockets.status.value || transcript.response?.status || "idle";
transcript.response?.status === "ended"
? "ended"
: webSockets.status.value || transcript.response?.status || "idle";
setStatus(newStatus);
if (newStatus && (newStatus == "ended" || newStatus == "error")) {
console.log(newStatus, "redirecting");

View File

@@ -566,8 +566,17 @@ export interface components {
user_id: string | null;
/** Name */
name: string;
/** Status */
status: string;
/**
* Status
* @enum {string}
*/
status:
| "idle"
| "uploaded"
| "recording"
| "processing"
| "error"
| "ended";
/** Locked */
locked: boolean;
/** Duration */
@@ -611,8 +620,17 @@ export interface components {
user_id: string | null;
/** Name */
name: string;
/** Status */
status: string;
/**
* Status
* @enum {string}
*/
status:
| "idle"
| "uploaded"
| "recording"
| "processing"
| "error"
| "ended";
/** Locked */
locked: boolean;
/** Duration */