-
Notifications
You must be signed in to change notification settings - Fork 0
fix: add processing page to file upload and reprocessing #650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
| useEffect(() => { | ||
| if (waiting) { | ||
| const newUrl = "/transcripts/" + params.transcriptId + "/record"; | ||
| if (!waiting || !transcript.data) return; | ||
|
|
||
| const status = transcript.data.status; | ||
| let newUrl: string | null = null; | ||
|
|
||
| if (status === "processing" || status === "uploaded") { | ||
| newUrl = `/transcripts/${params.transcriptId}/processing`; | ||
| } else if (status === "recording") { | ||
| newUrl = `/transcripts/${params.transcriptId}/record`; | ||
| } else if (status === "idle") { | ||
| newUrl = | ||
| transcript.data.source_kind === "file" | ||
| ? `/transcripts/${params.transcriptId}/upload` | ||
| : `/transcripts/${params.transcriptId}/record`; | ||
| } | ||
|
|
||
| if (newUrl) { | ||
| // Shallow redirection does not work on NextJS 13 | ||
| // https://github.com/vercel/next.js/discussions/48110 | ||
| // https://github.com/vercel/next.js/discussions/49540 | ||
| router.replace(newUrl); | ||
| // history.replaceState({}, "", newUrl); | ||
| } | ||
| }, [waiting]); | ||
| }, [waiting, transcript.data?.status, transcript.data?.source_kind]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add router and params to the dependency array of the useEffect hook to ensure the effect runs when these dependencies change. [possible issue, importance: 8]
| useEffect(() => { | |
| if (waiting) { | |
| const newUrl = "/transcripts/" + params.transcriptId + "/record"; | |
| if (!waiting || !transcript.data) return; | |
| const status = transcript.data.status; | |
| let newUrl: string | null = null; | |
| if (status === "processing" || status === "uploaded") { | |
| newUrl = `/transcripts/${params.transcriptId}/processing`; | |
| } else if (status === "recording") { | |
| newUrl = `/transcripts/${params.transcriptId}/record`; | |
| } else if (status === "idle") { | |
| newUrl = | |
| transcript.data.source_kind === "file" | |
| ? `/transcripts/${params.transcriptId}/upload` | |
| : `/transcripts/${params.transcriptId}/record`; | |
| } | |
| if (newUrl) { | |
| // Shallow redirection does not work on NextJS 13 | |
| // https://github.com/vercel/next.js/discussions/48110 | |
| // https://github.com/vercel/next.js/discussions/49540 | |
| router.replace(newUrl); | |
| // history.replaceState({}, "", newUrl); | |
| } | |
| }, [waiting]); | |
| }, [waiting, transcript.data?.status, transcript.data?.source_kind]); | |
| useEffect(() => { | |
| if (!waiting || !transcript.data) return; | |
| const status = transcript.data.status; | |
| let newUrl: string | null = null; | |
| if (status === "processing" || status === "uploaded") { | |
| newUrl = `/transcripts/${params.transcriptId}/processing`; | |
| } else if (status === "recording") { | |
| newUrl = `/transcripts/${params.transcriptId}/record`; | |
| } else if (status === "idle") { | |
| newUrl = | |
| transcript.data.source_kind === "file" | |
| ? `/transcripts/${params.transcriptId}/upload` | |
| : `/transcripts/${params.transcriptId}/record`; | |
| } | |
| if (newUrl) { | |
| // Shallow redirection does not work on NextJS 13 | |
| // https://github.com/vercel/next.js/discussions/48110 | |
| // https://github.com/vercel/next.js/discussions/49540 | |
| router.replace(newUrl); | |
| } | |
| }, [waiting, transcript.data?.status, transcript.data?.source_kind, router, params]); |
| if (transcript.isLoading) { | ||
| return ( | ||
| <VStack align="center" py={8}> | ||
| <Heading size="lg">Loading transcript...</Heading> | ||
| </VStack> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: The loading state check should also handle the case when transcript.data is undefined, as the useEffect logic depends on it. [possible issue, importance: 7]
| if (transcript.isLoading) { | |
| return ( | |
| <VStack align="center" py={8}> | |
| <Heading size="lg">Loading transcript...</Heading> | |
| </VStack> | |
| ); | |
| } | |
| if (transcript.isLoading || !transcript.data) { | |
| return ( | |
| <VStack align="center" py={8}> | |
| <Heading size="lg">Loading transcript...</Heading> | |
| </VStack> | |
| ); | |
| } |
| const status = transcript.data?.status; | ||
| if (!status) return; | ||
|
|
||
| if (status === "ended" || status === "error") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic dupe with www/app/(app)/transcripts/[transcriptId]/page.tsx - only allow dupes when it's different business processes
|
|
||
| type FileUploadButton = { | ||
| transcriptId: string; | ||
| onUploadComplete?: () => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "onComplete" (we already know it's Upload from the name)
User description
PR Type
Enhancement
Description
Add processing page for file uploads
Improve transcript status handling
Unify processing experience
Fix redirection logic
Changes walkthrough 📝
page.tsx
Improve transcript status handling and UIwww/app/(app)/transcripts/[transcriptId]/page.tsx
page.tsx
Add new processing page componentwww/app/(app)/transcripts/[transcriptId]/processing/page.tsx
page.tsx
Refactor upload page to use processing pagewww/app/(app)/transcripts/[transcriptId]/upload/page.tsx
fileUploadButton.tsx
Add completion callback to FileUploadButtonwww/app/(app)/transcripts/fileUploadButton.tsx