mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 21:42:27 +08:00
fix(video): handle queued status in video progress updates
Add 'queued' status to the SWR refresh conditions and restructure progress update logic to prevent potential race conditions when video status changes from queued to in_progress
This commit is contained in:
parent
c3c125f3a3
commit
c50a574982
@ -23,6 +23,7 @@ export const useOpenAIVideo = (id: string) => {
|
||||
const addOpenAIVideo = useAddOpenAIVideo(providerId)
|
||||
let options: SWRConfiguration = {}
|
||||
switch (video?.status) {
|
||||
case 'queued':
|
||||
case 'in_progress':
|
||||
options = {
|
||||
refreshInterval: 3000
|
||||
@ -39,12 +40,14 @@ export const useOpenAIVideo = (id: string) => {
|
||||
const revalidate = () => mutate(`video/openai/${id}`)
|
||||
|
||||
useEffect(() => {
|
||||
// update progress
|
||||
if (data && data.video.status === 'in_progress' && data.video.progress) {
|
||||
if (video) {
|
||||
updateVideo({ id: video.id, progress: data.video.progress })
|
||||
} else {
|
||||
addOpenAIVideo(data.video, 'Prompt lost')
|
||||
// queue -> in_progress / update progress
|
||||
if (data) {
|
||||
if (data.video.status === 'in_progress' && data.video.progress) {
|
||||
if (video) {
|
||||
updateVideo({ id: video.id, progress: data.video.progress })
|
||||
} else {
|
||||
addOpenAIVideo(data.video, 'Prompt lost')
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [addOpenAIVideo, data, updateVideo, video])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user