This commit is contained in:
ct
2025-07-16 12:38:06 +08:00
parent d4b69df538
commit d4c5fb5589
25 changed files with 249 additions and 86 deletions

View File

@@ -30,7 +30,7 @@ const VideoDownloadModal = ({
const lastProgressTime = useRef(null);
const lastProgress = useRef(0);
const { premiumExportRequest, premiumExportComplete } = useUserStore();
const { premiumExportRequest, premiumExportComplete, basicExportRequest, basicExportComplete } = useUserStore();
const handleShareOrDownload = async () => {
if (!videoBlob || !videoBlobFilename) {
@@ -116,11 +116,28 @@ const VideoDownloadModal = ({
}
};
const handleExportWithWatermark = () => {
const handleExportWithWatermark = async () => {
setIsPremiumExport(false);
setEstimatedTimeRemaining(null);
setStatus('processing');
handleDownloadButton();
// Call basicExportRequest and check response
const response = await basicExportRequest();
if (response?.error) {
// Halt the process if there's an error
setIsPremiumExport(false);
return;
}
if (response?.success) {
// Store the export token
const token = response.success.data.export_token;
console.log('Received basic export token:', token);
setExportToken(token);
// Continue with export if successful
setStatus('processing');
handleDownloadButton();
}
};
const handleClose = async () => {
@@ -140,15 +157,18 @@ const VideoDownloadModal = ({
useEffect(() => {
if (status === 'processing' && exportProgress >= 100) {
setStatus('complete');
// Call premiumExportComplete immediately when export completes
// Call appropriate export complete method based on export type
if (isPremiumExport && exportToken) {
console.log('Calling premiumExportComplete with token:', exportToken);
premiumExportComplete(exportToken);
} else if (isPremiumExport && !exportToken) {
console.error('Premium export completed but no token available');
} else if (!isPremiumExport && exportToken) {
console.log('Calling basicExportComplete with token:', exportToken);
basicExportComplete(exportToken);
} else if (!exportToken) {
console.error('Export completed but no token available');
}
}
}, [exportProgress, status, isPremiumExport, exportToken, premiumExportComplete]);
}, [exportProgress, status, isPremiumExport, exportToken, premiumExportComplete, basicExportComplete]);
// Calculate estimated time remaining based on progress speed
useEffect(() => {