experiment(PodcastPlayerView): add Retry button to failedView, clear pollingTask on failure

This commit is contained in:
Krishna Kumar
2026-05-23 00:52:55 -05:00
parent f7d5c129fc
commit 140c761850

View File

@@ -97,6 +97,7 @@ final class PodcastPlayerViewModel {
let errMsg = job.error ?? "Generation failed" let errMsg = job.error ?? "Generation failed"
Analytics.track("podcast.failed", ["url": articleUrl, "error": errMsg]) Analytics.track("podcast.failed", ["url": articleUrl, "error": errMsg])
phase = .failed(errMsg) phase = .failed(errMsg)
pollingTask = nil
return return
} }
try await Task.sleep(for: .seconds(3)) try await Task.sleep(for: .seconds(3))
@@ -105,6 +106,7 @@ final class PodcastPlayerViewModel {
} catch { } catch {
Analytics.track("podcast.failed", ["url": articleUrl, "error": error.localizedDescription]) Analytics.track("podcast.failed", ["url": articleUrl, "error": error.localizedDescription])
phase = .failed(error.localizedDescription) phase = .failed(error.localizedDescription)
pollingTask = nil
} }
} }
} }
@@ -434,6 +436,18 @@ struct PodcastPlayerView: View {
.font(.system(size: 14)) .font(.system(size: 14))
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
.multilineTextAlignment(.center) .multilineTextAlignment(.center)
Button {
vm.start(articleUrl: articleUrl, articleTitle: articleTitle, claude: claude)
} label: {
Label("Retry", systemImage: "arrow.clockwise")
.font(.system(size: 15, weight: .semibold))
.foregroundStyle(.white)
.padding(.horizontal, 24)
.padding(.vertical, 10)
.background(Color.blue)
.clipShape(Capsule())
}
.padding(.top, 4)
} }
} }