Skip to content

Commit 07e2d92

Browse files
committed
fix(studio): move early returns after hooks in TranslationsView
Move the storyboardDone and isLoading early returns below the useMemo hook to comply with React's rules of hooks (no conditional returns before hooks).
1 parent 50b9fcc commit 07e2d92

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

apps/studio/src/components/pipeline/stages/translations/TranslationsView.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -557,19 +557,6 @@ export function TranslationsView({ bookLabel, stageSlug = "translate", selectedP
557557
return () => setExtra(null)
558558
}, [catalog, t, displayEntries.length, outputLanguages.length, selectedLang, translationVersion, saving, dirty, bookLabel, isSourceLang, totalAudioFiles, selectedPageId, currentLanguageUsesGemini, generatedAudioCount, missingAudioCount, hasApiKey, isRunning, apiKey, queueRun, stageSlug, isSpeechStage, handleDeleteTTS, audioLang, transcribeAllMutation, isTaskRunning])
559559

560-
if (!storyboardDone) {
561-
return <StoryboardRequired action={isSpeechStage ? "generating speech" : "translating"} />
562-
}
563-
564-
if (!showRunCard && isLoading) {
565-
return (
566-
<div className="flex items-center justify-center py-12 text-muted-foreground">
567-
<Loader2 className="w-4 h-4 animate-spin mr-2" />
568-
<span className="text-sm">{t`Loading text catalog...`}</span>
569-
</div>
570-
)
571-
}
572-
573560
// Resolve speech config summary for display
574561
const speechSummary = useMemo(() => {
575562
if (!speechConfig || typeof speechConfig !== "object") {
@@ -584,6 +571,19 @@ export function TranslationsView({ bookLabel, stageSlug = "translate", selectedP
584571
return { provider, voice, model: providerModel ?? model ?? "gpt-4o-mini-tts" }
585572
}, [speechConfig])
586573

574+
if (!storyboardDone) {
575+
return <StoryboardRequired action={isSpeechStage ? "generating speech" : "translating"} />
576+
}
577+
578+
if (!showRunCard && isLoading) {
579+
return (
580+
<div className="flex items-center justify-center py-12 text-muted-foreground">
581+
<Loader2 className="w-4 h-4 animate-spin mr-2" />
582+
<span className="text-sm">{t`Loading text catalog...`}</span>
583+
</div>
584+
)
585+
}
586+
587587
if (showRunCard || !catalog || entries.length === 0) {
588588
return (
589589
<div className="p-4">

0 commit comments

Comments
 (0)