fix(result): remove download if video generation failed

This commit is contained in:
Harshad 2026-02-12 17:18:55 +05:30
parent 51eae23183
commit ee0997c97f
2 changed files with 23 additions and 2 deletions

View file

@ -19,6 +19,7 @@ document.addEventListener('alpine:init', () => {
isDownloadReady: false,
copyBtnText: 'Copy URL',
scrollAnimationId: null,
videoGenerationFailed: false,
hasError: false,
errorTitle: '',
errorMessage: '',
@ -180,6 +181,13 @@ document.addEventListener('alpine:init', () => {
const response = await fetch(`${API_BASE_URL}/api/results/${this.sessionId}`);
const data = await response.json();
// Check if video generation failed
if (data.success === false || data.status === 'fail') {
console.log('[Result API] Video generation failed.');
this.videoGenerationFailed = true;
return true; // Stop polling
}
if (data.pet_name) {
//this.petName = data.pet_name.toLowerCase().replace(/\s+/g, '-');
//this.petName = `${data.pet_name}'s`;
@ -323,6 +331,11 @@ document.addEventListener('alpine:init', () => {
if (this.isDownloadReady) {
return null; // No status text when ready
}
if (this.videoGenerationFailed) {
return null; // Hide status when video failed
}
if (this.timerEnded && !this.videoUrl) {
return 'Your video is still processing, almost there...';
}

View file

@ -104,15 +104,23 @@
<a
:href="$store.songApp.isDownloadReady ? 'https://valentinesong.oliver.digital/back/api/download/' + $store.songApp.sessionId : 'javascript:void(0);'"
class="download-song-btn"
class="download-song-btn"
:class="{ 'disabled-cta': !$store.songApp.isDownloadReady }"
x-show="!$store.songApp.videoGenerationFailed"
>Download now to keep your song</a>
<template x-if="$store.songApp.downloadStatusText">
<div class="share-subtext" x-text="$store.songApp.downloadStatusText"></div>
</template>
<div class="share-subtext">After downloading, youll find your Pet Love Song in Files (iPhone) or Downloads (Android).</div>
<div class="share-subtext">
<template x-if="$store.songApp.videoGenerationFailed">
<span>Unfortunately, the video couldn't be generated. Please create a new song to try again.</span>
</template>
<template x-if="!$store.songApp.videoGenerationFailed">
<span>After downloading, you'll find your Pet Love Song in 'Files' (iPhone) or 'Downloads' (Android).</span>
</template>
</div>
</div>
<a href="/" class="make-another-song-btn"