From 220df84777b657b7349250f12ca41b6d1b2e2d5e Mon Sep 17 00:00:00 2001 From: Hugo Gresse Date: Wed, 24 Jul 2024 16:21:23 +0200 Subject: [PATCH] Fix error in generation dialog not always displayed (#136) --- .../sessions/generation/useSessionsGenerationGeneric.ts | 4 ++++ .../sessions/components/GenerateSessionsVideoDialog.tsx | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/events/actions/sessions/generation/useSessionsGenerationGeneric.ts b/src/events/actions/sessions/generation/useSessionsGenerationGeneric.ts index 7025229..9ed78d2 100644 --- a/src/events/actions/sessions/generation/useSessionsGenerationGeneric.ts +++ b/src/events/actions/sessions/generation/useSessionsGenerationGeneric.ts @@ -56,6 +56,7 @@ export const useSessionsGenerationGeneric = < ): Promise<{ success: boolean results: any[] + message?: string }> => { const sessionsCount = sessions.length @@ -82,6 +83,9 @@ export const useSessionsGenerationGeneric = < return { success: false, results: [], + message: + answer.message || + 'Unknown error while generating the video/image, you may want to switch the ShortVid server', } } diff --git a/src/events/page/sessions/components/GenerateSessionsVideoDialog.tsx b/src/events/page/sessions/components/GenerateSessionsVideoDialog.tsx index e549b71..79e9fd4 100644 --- a/src/events/page/sessions/components/GenerateSessionsVideoDialog.tsx +++ b/src/events/page/sessions/components/GenerateSessionsVideoDialog.tsx @@ -66,7 +66,7 @@ export const GenerateSessionsVideoDialog = ({ ...shortVidSetting, updateSession: updateDoc, }) - .then(({ success, results }: GeneratedSessionVideoAnswer) => { + .then(({ success, results, message }: GeneratedSessionVideoAnswer) => { if (success && results.length) { const text = onSuccess ? 'Video generation done!' : 'Video generation done, sessions updated!' if (onSuccess) { @@ -76,7 +76,7 @@ export const GenerateSessionsVideoDialog = ({ onClose() } else { createNotification( - 'Error while generating the video/image, you may want to switch the ShortVid server', + message || 'Error while generating the video/image, you may want to switch the ShortVid server', { type: 'error' } ) } @@ -145,6 +145,9 @@ export const GenerateSessionsVideoDialog = ({ {generatingState.generationState === GenerationStates.ERROR && ( {generatingState.message} )} + {finalGeneration.generatingState.generationState === GenerationStates.ERROR && ( + {finalGeneration.generatingState.message} + )} {generatingState.generationState === GenerationStates.SUCCESS && ( <>