video_id 추가
parent
1569ead56c
commit
29e0c7d79c
|
|
@ -21,6 +21,7 @@ interface SavedVideoState {
|
|||
songTaskId: string;
|
||||
status: VideoStatus;
|
||||
videoUrl: string | null;
|
||||
videoDbId?: number;
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
|
|
@ -70,12 +71,13 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
}
|
||||
}, [renderProgress, onVideoProgressChange]);
|
||||
|
||||
const saveToStorage = (videoTaskId: string, currentSongTaskId: string, status: VideoStatus, url: string | null) => {
|
||||
const saveToStorage = (videoTaskId: string, currentSongTaskId: string, status: VideoStatus, url: string | null, dbId?: number) => {
|
||||
const data: SavedVideoState = {
|
||||
videoTaskId,
|
||||
songTaskId: currentSongTaskId,
|
||||
status,
|
||||
videoUrl: url,
|
||||
videoDbId: dbId,
|
||||
timestamp: Date.now(),
|
||||
};
|
||||
localStorage.setItem(VIDEO_STORAGE_KEY, JSON.stringify(data));
|
||||
|
|
@ -84,6 +86,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
const completeData = {
|
||||
songTaskId: currentSongTaskId,
|
||||
videoUrl: url,
|
||||
videoDbId: dbId,
|
||||
completedAt: Date.now(),
|
||||
};
|
||||
localStorage.setItem(VIDEO_COMPLETE_KEY, JSON.stringify(completeData));
|
||||
|
|
@ -94,7 +97,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
localStorage.removeItem(VIDEO_STORAGE_KEY);
|
||||
};
|
||||
|
||||
const loadCompleteVideo = (): { songTaskId: string; videoUrl: string } | null => {
|
||||
const loadCompleteVideo = (): { songTaskId: string; videoUrl: string; videoDbId?: number } | null => {
|
||||
try {
|
||||
const saved = localStorage.getItem(VIDEO_COMPLETE_KEY);
|
||||
if (!saved) return null;
|
||||
|
|
@ -203,14 +206,14 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
const videoUrlFromResponse = statusResponse.render_data?.url;
|
||||
|
||||
if (videoUrlFromResponse) {
|
||||
setVideoUrl(videoUrlFromResponse);
|
||||
const videoId = statusResponse.render_data?.video_id;
|
||||
setVideoUrl(videoUrlFromResponse);
|
||||
if (videoId) {
|
||||
setVideoDbId(videoId);
|
||||
}
|
||||
setVideoStatus('complete');
|
||||
setStatusMessage('');
|
||||
saveToStorage(videoTaskId, currentSongTaskId, 'complete', videoUrlFromResponse);
|
||||
saveToStorage(videoTaskId, currentSongTaskId, 'complete', videoUrlFromResponse, videoId);
|
||||
} else {
|
||||
throw new Error(t('completion.videoUrlMissing'));
|
||||
}
|
||||
|
|
@ -237,6 +240,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
const completeVideo = loadCompleteVideo();
|
||||
if (completeVideo && completeVideo.songTaskId === songTaskId && completeVideo.videoUrl) {
|
||||
setVideoUrl(completeVideo.videoUrl);
|
||||
if (completeVideo.videoDbId) setVideoDbId(completeVideo.videoDbId);
|
||||
setVideoStatus('complete');
|
||||
hasStartedGeneration.current = true;
|
||||
return;
|
||||
|
|
@ -247,6 +251,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
if (savedState && savedState.songTaskId === songTaskId) {
|
||||
if (savedState.status === 'complete' && savedState.videoUrl) {
|
||||
setVideoUrl(savedState.videoUrl);
|
||||
if (savedState.videoDbId) setVideoDbId(savedState.videoDbId);
|
||||
setVideoStatus('complete');
|
||||
hasStartedGeneration.current = true;
|
||||
} else if (savedState.status === 'polling') {
|
||||
|
|
@ -506,7 +511,7 @@ const CompletionContent: React.FC<CompletionContentProps> = ({
|
|||
</button>
|
||||
<button
|
||||
onClick={handleOpenSocialConnect}
|
||||
disabled={videoStatus !== 'complete'}
|
||||
disabled={videoStatus !== 'complete' || !videoDbId}
|
||||
className="comp2-btn comp2-btn-primary"
|
||||
>
|
||||
{t('completion.uploadToSocial', { defaultValue: '소셜 채널 업로드' })}
|
||||
|
|
|
|||
Loading…
Reference in New Issue