progress && remove video

This commit is contained in:
2025-10-20 14:54:45 +02:00
parent 2cb3af13e2
commit cab9e7dc28
3 changed files with 60 additions and 26 deletions
+20 -4
View File
@@ -36,6 +36,7 @@ const GeneratingSong = () => {
// Progress based on 8 minutes cap or until status becomes GENERATED
useEffect(() => {
const totalMs = 8 * 60 * 1000;
const maxGeneratingProgress = 90;
const clearTimer = () => {
if (progressTimerRef.current) {
global.clearInterval(progressTimerRef.current);
@@ -44,6 +45,10 @@ const GeneratingSong = () => {
};
const status = selectedProject?.musicStatus;
const readyUrls = Array.isArray(selectedProject?.musicUrls)
? selectedProject.musicUrls.filter(Boolean)
: [];
const hasReadySong = readyUrls.length > 0 || !!selectedProject?.songUrl;
if (status !== "GENERATING") {
// Reset local start when leaving generating state
@@ -51,8 +56,14 @@ const GeneratingSong = () => {
}
if (status === "GENERATED") {
setProgress(100);
clearTimer();
setProgress(hasReadySong ? 100 : maxGeneratingProgress);
return () => clearTimer();
}
if (status !== "GENERATING") {
clearTimer();
setProgress(0);
return () => clearTimer();
}
@@ -75,8 +86,8 @@ const GeneratingSong = () => {
}
const elapsed = moment().diff(moment(startDate));
const raw = Math.floor((elapsed / totalMs) * 100);
// While status is GENERATING, block visual progress at 99%
const pct = Math.max(0, Math.min(99, raw));
// While status is GENERATING, block visual progress at 90%
const pct = Math.max(0, Math.min(maxGeneratingProgress, raw));
setProgress(pct);
};
@@ -84,7 +95,12 @@ const GeneratingSong = () => {
clearTimer();
progressTimerRef.current = global.setInterval(update, 1000);
return () => clearTimer();
}, [selectedProject?.musicStatus, selectedProject?.generationStartAt]);
}, [
selectedProject?.musicStatus,
selectedProject?.generationStartAt,
selectedProject?.musicUrls,
selectedProject?.songUrl,
]);
// Auto navigate to SongReady when generation completed
useEffect(() => {