fix(video): handle undefined video case in VideoPanel

Add conditional check to handle undefined video case and show toast for unimplemented remix video feature.
This commit is contained in:
icarus 2025-10-12 08:09:19 +08:00
parent 7bde37680e
commit ae54d5d9b9

View File

@ -48,6 +48,7 @@ export const VideoPanel = ({ provider, video, params, updateParams }: VideoPanel
if (!couldCreateVideo) return if (!couldCreateVideo) return
setIsProcessing(true) setIsProcessing(true)
try { try {
if (video === undefined) {
const result = await createVideo(params) const result = await createVideo(params)
const video = result.video const video = result.video
switch (result.type) { switch (result.type) {
@ -57,12 +58,16 @@ export const VideoPanel = ({ provider, video, params, updateParams }: VideoPanel
default: default:
logger.error(`Invalid video type ${result.type}.`) logger.error(`Invalid video type ${result.type}.`)
} }
} else {
// TODO: remix video
window.toast.info('Remix video is not implemented.')
}
} catch (e) { } catch (e) {
window.toast.error({ title: t('video.error.create'), description: getErrorMessage(e), timeout: 5000 }) window.toast.error({ title: t('video.error.create'), description: getErrorMessage(e), timeout: 5000 })
} finally { } finally {
setIsProcessing(false) setIsProcessing(false)
} }
}, [addOpenAIVideo, couldCreateVideo, params, t]) }, [addOpenAIVideo, couldCreateVideo, params, t, video])
const handleUploadFile = useCallback(() => { const handleUploadFile = useCallback(() => {
fileInputRef.current?.click() fileInputRef.current?.click()