mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 21:42:27 +08:00
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:
parent
7bde37680e
commit
ae54d5d9b9
@ -48,21 +48,26 @@ export const VideoPanel = ({ provider, video, params, updateParams }: VideoPanel
|
||||
if (!couldCreateVideo) return
|
||||
setIsProcessing(true)
|
||||
try {
|
||||
const result = await createVideo(params)
|
||||
const video = result.video
|
||||
switch (result.type) {
|
||||
case 'openai':
|
||||
addOpenAIVideo(video)
|
||||
break
|
||||
default:
|
||||
logger.error(`Invalid video type ${result.type}.`)
|
||||
if (video === undefined) {
|
||||
const result = await createVideo(params)
|
||||
const video = result.video
|
||||
switch (result.type) {
|
||||
case 'openai':
|
||||
addOpenAIVideo(video)
|
||||
break
|
||||
default:
|
||||
logger.error(`Invalid video type ${result.type}.`)
|
||||
}
|
||||
} else {
|
||||
// TODO: remix video
|
||||
window.toast.info('Remix video is not implemented.')
|
||||
}
|
||||
} catch (e) {
|
||||
window.toast.error({ title: t('video.error.create'), description: getErrorMessage(e), timeout: 5000 })
|
||||
} finally {
|
||||
setIsProcessing(false)
|
||||
}
|
||||
}, [addOpenAIVideo, couldCreateVideo, params, t])
|
||||
}, [addOpenAIVideo, couldCreateVideo, params, t, video])
|
||||
|
||||
const handleUploadFile = useCallback(() => {
|
||||
fileInputRef.current?.click()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user