feat(episodes): let owners remove episodes from the RSS feed

Adds an "unlisted" flag on episodes rather than reusing the existing
hard-delete route, since a hard delete cascades to purchases/earnings
(ON DELETE CASCADE) and would wipe a producer's sales history and any
unwithdrawn earnings for that episode. Unlisting only affects feed.xml
output — the episode, its purchases, and reseller listings all stay
intact and it can be relisted at any time.

Wires up the missing frontend for it too: the podcast settings page
had no episode list or management controls at all before this, despite
the backend already exposing full episode CRUD.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-09 21:14:23 +00:00
co-authored by Claude Sonnet 5
parent 69241a28b1
commit 5ebea55353
6 changed files with 110 additions and 4 deletions
+63 -1
View File
@@ -4,18 +4,30 @@ import { useRoute, useRouter } from 'vue-router';
import { api } from '../lib/api';
import PodcastForm, { type PodcastPayload } from '../components/PodcastForm.vue';
interface Episode {
id: string;
title: string;
pub_date: number;
unlisted: number;
}
const route = useRoute();
const router = useRouter();
const podcastId = route.params.id as string;
const podcast = ref<(PodcastPayload & { id: string }) | null>(null);
const episodes = ref<Episode[]>([]);
const loading = ref(true);
const error = ref('');
const saved = ref(false);
const episodeError = ref('');
const busyEpisodeId = ref('');
onMounted(async () => {
try {
podcast.value = await api.get<PodcastPayload & { id: string }>(`/api/podcasts/${podcastId}`);
const data = await api.get<PodcastPayload & { id: string; episodes: Episode[] }>(`/api/podcasts/${podcastId}`);
podcast.value = data;
episodes.value = data.episodes;
} catch (err) {
error.value = (err as Error).message;
} finally {
@@ -27,6 +39,23 @@ function onSaved(): void {
saved.value = true;
setTimeout(() => router.push('/'), 800);
}
async function toggleListed(ep: Episode): Promise<void> {
const nextUnlisted = !ep.unlisted;
if (nextUnlisted && !confirm(`Remove "${ep.title}" from the RSS feed? It stays in your library and can be added back later.`)) {
return;
}
episodeError.value = '';
busyEpisodeId.value = ep.id;
try {
const updated = await api.put<Episode>(`/api/podcasts/${podcastId}/episodes/${ep.id}`, { unlisted: nextUnlisted });
ep.unlisted = updated.unlisted;
} catch (err) {
episodeError.value = (err as Error).message;
} finally {
busyEpisodeId.value = '';
}
}
</script>
<template>
@@ -40,5 +69,38 @@ function onSaved(): void {
Saved.
</p>
</div>
<div v-if="!loading && !error" class="card">
<h2 class="mb-1 text-lg font-semibold">Episodes</h2>
<p class="mb-4 text-xs text-white/30">
Removing an episode from the feed hides it from RSS/podcast apps but keeps it in your
library — sales history, reseller listings, and the uploaded file are untouched, and you
can add it back any time.
</p>
<p v-if="episodeError" class="mb-3 rounded-lg bg-red-500/20 border border-red-500/40 p-3 text-sm text-red-200">
{{ episodeError }}
</p>
<p v-if="!episodes.length" class="text-sm text-white/50">No episodes yet.</p>
<ul v-else class="space-y-2">
<li v-for="ep in episodes" :key="ep.id" class="flex items-center justify-between gap-4 rounded-lg bg-white/5 p-3">
<div class="min-w-0">
<p class="truncate font-medium" :class="{ 'text-white/40': ep.unlisted }">{{ ep.title }}</p>
<p class="text-xs text-white/30">
{{ new Date(ep.pub_date * 1000).toLocaleDateString() }}
<span v-if="ep.unlisted" class="ml-2 rounded-full bg-amber-500/20 px-2 py-0.5 text-amber-300">
Removed from feed
</span>
</p>
</div>
<button
class="btn-secondary shrink-0 whitespace-nowrap !py-1.5 !px-3 text-sm"
:disabled="busyEpisodeId === ep.id"
@click="toggleListed(ep)"
>
{{ busyEpisodeId === ep.id ? 'Working…' : ep.unlisted ? 'Add back to feed' : 'Remove from feed' }}
</button>
</li>
</ul>
</div>
</div>
</template>