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

@@ -27,6 +27,7 @@ from reflector.db.search import (
from reflector.db.transcripts import ( from reflector.db.transcripts import (
SourceKind, SourceKind,
TranscriptParticipant, TranscriptParticipant,
TranscriptStatus,
TranscriptTopic, TranscriptTopic,
transcripts_controller, transcripts_controller,
) )
@@ -63,7 +64,7 @@ class GetTranscriptMinimal(BaseModel):
id: str id: str
user_id: str | None user_id: str | None
name: str name: str
status: str status: TranscriptStatus
locked: bool locked: bool
duration: float duration: float
title: str | None title: str | None

View File

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

View File

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