From 8c32cd117abe79f4ee6cff3a950ffc35c95faeff Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 9 May 2026 11:11:49 +0300 Subject: Refine media browsing and set covers --- web/js/podcasts.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'web/js/podcasts.js') diff --git a/web/js/podcasts.js b/web/js/podcasts.js index 4692f7b..c8c088e 100644 --- a/web/js/podcasts.js +++ b/web/js/podcasts.js @@ -9,7 +9,6 @@ export function initPodcasts() { const closeBtn = document.getElementById('podcast-close'); const form = document.getElementById('podcast-form'); const urlInput = document.getElementById('podcast-url'); - const nameInput = document.getElementById('podcast-name'); const listEl = document.getElementById('podcast-list'); const adminBtn = document.getElementById('admin-podcasts'); @@ -26,13 +25,11 @@ export function initPodcasts() { form?.addEventListener('submit', async (e) => { e.preventDefault(); const url = urlInput.value.trim(); - const name = nameInput.value.trim(); if (!url) return; try { - await API.subscribePodcast(url, name); + await API.subscribePodcast(url, ''); toast('Subscribed to podcast'); urlInput.value = ''; - nameInput.value = ''; refreshPodcasts(); refreshSets(); } catch (err) { @@ -50,9 +47,9 @@ export function initPodcasts() { } listEl.innerHTML = podcasts.map(p => `
- - ${escapeHtml(p.name)} - ${escapeHtml(p.root_path)} + + ${escapeHtml(p.title || p.feed_url)} + ${escapeHtml(p.feed_url)}
` ).join(''); } catch (err) { @@ -70,19 +67,26 @@ export function initPodcasts() { } } -export function renderPodcastEpisodes(grid, episodes) { +export function renderPodcastEpisodes(grid, episodes, options = {}) { if (!episodes || !episodes.length) return; + const append = (node) => { + if (options.before) { + grid.insertBefore(node, options.before); + } else { + grid.appendChild(node); + } + }; const divider = document.createElement('div'); divider.className = 'grid-divider'; divider.textContent = 'Podcast Episodes'; - grid.appendChild(divider); + append(divider); episodes.forEach(ep => { const card = document.createElement('div'); card.className = 'media-card episode-card'; card.dataset.id = ep.id; renderEpisodeCard(card, ep); - grid.appendChild(card); + append(card); }); } -- cgit v1.2.3