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