Add the share toggle and privacy dialog to the podcast page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
sanapachandClaude Opus 5.5 committed 2026-11-20 15:12:51 +02:00
1 parent 588ea4e99e
commit 74ad88d06e
6 files changed
+318 -2

No files matched your search

+23
View File
@@ -48,6 +48,29 @@
</div>
</template>
<!-- Podcast: confirm publishing a feed URL that looks private -->
<template x-if="$store.podcasts.shareDialog">
<div class="modal-overlay" @click.self="$store.podcasts.cancelShare()" @keydown.escape.window="$store.podcasts.cancelShare()">
<div class="modal-box podcast-share-dialog" role="dialog" aria-modal="true" aria-labelledby="podcast-share-dialog-title">
<h3 id="podcast-share-dialog-title">{{ t.player_podcast_share_dialog_title }}</h3>
<p class="podcast-share-dialog-title" x-text="$store.podcasts.shareDialog.title"></p>
<p>{{ t.player_podcast_share_dialog_text }}</p>
<ul class="podcast-share-warnings">
<template x-for="(warning, index) in $store.podcasts.shareDialog.warnings" :key="index">
<li x-text="$store.podcasts.warningText(warning)"></li>
</template>
</ul>
<div class="podcast-share-url" x-text="$store.podcasts.shareDialog.feed_url"></div>
<div class="podcast-share-url" x-show="$store.podcasts.shareDialog.id_feed_url" x-text="$store.podcasts.shareDialog.id_feed_url"></div>
<p class="podcast-share-hint">{{ t.player_podcast_share_dialog_hint }}</p>
<div class="modal-footer">
<button class="modal-btn modal-btn-ghost" x-init="$nextTick(() => $el.focus())" @click="$store.podcasts.cancelShare()">{{ t.player_cancel }}</button>
<button class="modal-btn modal-btn-danger" @click="$store.podcasts.confirmShare()">{{ t.player_podcast_share_dialog_confirm }}</button>
</div>
</div>
</div>
</template>
<!-- Create / Rename Playlist Modal -->
<template x-if="$store.playlists.modal">
<div class="modal-overlay" @click.self="$store.playlists.modal = null">
+113
View File
@@ -75,6 +75,17 @@ const T = {
podcastFetchError: "{{ t.player_podcast_fetch_error }}",
podcastNextCheck: "{{ t.player_podcast_next_check }}",
podcastUnsubscribeConfirm: "{{ t.player_podcast_unsubscribe_confirm }}",
podcastSharePrivate: "{{ t.player_podcast_share_private }}",
podcastSharePublished: "{{ t.player_podcast_share_published }}",
podcastSharePublishing: "{{ t.player_podcast_share_publishing }}",
podcastShareDiscoveryOff: "{{ t.player_podcast_share_discovery_off }}",
podcastSharePending: "{{ t.player_podcast_share_pending }}",
podcastShareUnavailable: "{{ t.player_podcast_share_unavailable }}",
podcastWarningSecretQuery: "{{ t.player_podcast_warning_secret_query }}",
podcastWarningPrivateHost: "{{ t.player_podcast_warning_private_host }}",
podcastWarningEntropyQuery: "{{ t.player_podcast_warning_entropy_query }}",
podcastWarningEntropyPath: "{{ t.player_podcast_warning_entropy_path }}",
podcastWarningOther: "{{ t.player_podcast_warning_other }}",
podcastSeason: "{{ t.player_podcast_season }}",
podcastNoSeason: "{{ t.player_podcast_no_season }}",
podcastLeft: "{{ t.player_podcast_left }}",
@@ -3677,6 +3688,10 @@ document.addEventListener('alpine:init', () => {
refreshing: false,
refreshMessage: '',
actionError: '',
share: null,
sharing: false,
shareError: '',
shareDialog: null,
busy: {},
expanded: {},
_searchTimer: null,
@@ -3761,9 +3776,12 @@ document.addEventListener('alpine:init', () => {
this.sort = 'newest';
this.query = '';
this.expanded = {};
this.share = null;
this.shareDialog = null;
}
this.refreshMessage = '';
this.actionError = '';
this.shareError = '';
this.detailError = '';
this._enterView('podcast_detail', '#podcast?id=' + encodeURIComponent(podcastId), options);
this.loadDetail(podcastId);
@@ -3777,6 +3795,7 @@ document.addEventListener('alpine:init', () => {
const data = await this._json(`/api/podcasts/feeds/${podcastId}`);
if (token !== this._detailToken) return;
this.current = data.podcast;
this.share = data.share || null;
this.seasons = Array.isArray(data.seasons) ? data.seasons : [];
this.history = Array.isArray(data.history) ? data.history : [];
this.detailError = '';
@@ -3849,6 +3868,8 @@ document.addEventListener('alpine:init', () => {
try {
this.current = await this._json(`/api/podcasts/feeds/${podcast.podcast_id}/unsubscribe`, { method: 'POST' });
this.loadList();
// Unsubscribing also revokes sharing.
this.loadDetail(podcast.podcast_id);
} catch (error) {
this.actionError = error.message;
}
@@ -3861,11 +3882,103 @@ document.addEventListener('alpine:init', () => {
try {
this.current = await this._json(`/api/podcasts/feeds/${podcast.podcast_id}/subscribe`, { method: 'POST' });
this.loadList();
// A new subscription is private until shared again.
this.loadDetail(podcast.podcast_id);
} catch (error) {
this.actionError = error.message;
}
},
// Sharing in the federation: the account's synced decision; the
// server's node publishes the card. A feed URL that looks private
// (token in the query, member-feed host...) is published only after
// the user confirms exactly the URLs shown in the dialog.
toggleShare() {
const share = this.share;
if (!this.current || !share || this.sharing) return;
if (share.shared) return this._setShare(false);
if (Array.isArray(share.warnings) && share.warnings.length) return this.reviewShare();
return this._setShare(true);
},
reviewShare(share = this.share) {
const podcast = this.current;
if (!podcast || !share || !share.feed_url) return;
this.shareDialog = {
podcastId: podcast.podcast_id,
title: podcast.title,
warnings: Array.isArray(share.warnings) ? share.warnings : [],
feed_url: share.feed_url,
id_feed_url: share.id_feed_url || null,
};
},
cancelShare() {
this.shareDialog = null;
},
confirmShare() {
const dialog = this.shareDialog;
this.shareDialog = null;
if (!dialog || this.current?.podcast_id !== dialog.podcastId) return;
return this._setShare(true, { feed_url: dialog.feed_url, id_feed_url: dialog.id_feed_url });
},
async _setShare(shared, confirm = null) {
const podcastId = this.current?.podcast_id;
if (!podcastId || this.sharing) return;
this.sharing = true;
this.shareError = '';
try {
const body = { shared };
if (confirm) body.confirm = confirm;
const res = await fetch(`/api/podcasts/feeds/${podcastId}/share`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
let data = null;
try { data = await res.json(); } catch {}
if (this.current?.podcast_id !== podcastId) return;
if (res.status === 409 && data?.needs_confirmation && data.share) {
// The URLs changed (or were never confirmed): ask about
// what the server would publish now.
this.share = data.share;
this.reviewShare(data.share);
} else if (!res.ok) {
throw new Error(data?.error || T.podcastRequestFailed);
} else {
if (data?.podcast) this.current = data.podcast;
this.share = data?.share || this.share;
this.loadList();
}
} catch (error) {
if (this.current?.podcast_id === podcastId) this.shareError = error.message;
} finally {
this.sharing = false;
}
},
shareStatus() {
const share = this.share;
if (!share) return '';
if (!share.shared) return share.card_error ? T.podcastShareUnavailable : T.podcastSharePrivate;
if (share.pending_confirmation) return T.podcastSharePending;
if (share.discovery !== 'running') return T.podcastShareDiscoveryOff;
return share.published ? T.podcastSharePublished : T.podcastSharePublishing;
},
warningText(warning) {
const name = warning?.name || '';
switch (warning?.reason) {
case 'secret_query_parameter': return T.podcastWarningSecretQuery.replace('{name}', name);
case 'private_feed_host': return T.podcastWarningPrivateHost.replace('{host}', warning.host || '');
case 'high_entropy_query_value': return T.podcastWarningEntropyQuery.replace('{name}', name);
case 'high_entropy_path_segment': return T.podcastWarningEntropyPath;
default: return T.podcastWarningOther;
}
},
jamBlocked() {
// A Jam guest controls the host's queue: episodes are private.
return !!Alpine.store('devices')?.isControllingRemoteJam?.();
+24
View File
@@ -762,6 +762,7 @@
<div class="card-subtitle" x-text="podcast.author || ''"></div>
<div class="card-subtitle" x-text="$store.podcasts.podcastCounts(podcast)"></div>
<div class="card-subtitle podcast-unsubscribed-label" x-show="!podcast.subscribed" x-cloak>{{ t.player_podcast_unsubscribed }}</div>
<div class="card-subtitle podcast-shared-label" x-show="podcast.subscribed && podcast.shared" x-cloak>{{ t.player_podcast_shared_badge }}</div>
<div class="card-subtitle podcast-fetch-error"
x-show="podcast.fetch && podcast.fetch.last_error"
x-cloak
@@ -824,6 +825,17 @@
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 11-3-6.7L21 8"/><path d="M21 3v5h-5"/></svg>
<span x-text="$store.podcasts.refreshing ? '{{ t.player_podcast_refreshing }}' : '{{ t.player_podcast_refresh }}'"></span>
</button>
<button class="release-action-btn secondary podcast-share-toggle"
x-show="$store.podcasts.current.subscribed && $store.podcasts.share"
x-cloak
:class="{ active: $store.podcasts.share && $store.podcasts.share.shared }"
:aria-pressed="$store.podcasts.share && $store.podcasts.share.shared ? 'true' : 'false'"
:disabled="$store.podcasts.sharing || !$store.podcasts.share || (!$store.podcasts.share.shared && !$store.podcasts.share.can_share)"
:title="$store.podcasts.share && $store.podcasts.share.card_error ? '{{ t.player_podcast_share_unavailable }}' : ''"
@click="$store.podcasts.toggleShare()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.6" y1="13.5" x2="15.4" y2="17.5"/><line x1="15.4" y1="6.5" x2="8.6" y2="10.5"/></svg>
<span x-text="$store.podcasts.sharing ? '{{ t.player_podcast_sharing }}' : ($store.podcasts.share && $store.podcasts.share.shared ? '{{ t.player_podcast_unshare }}' : '{{ t.player_podcast_share }}')"></span>
</button>
<button class="release-action-btn secondary podcast-unsubscribe"
x-show="$store.podcasts.current.subscribed"
@click="$store.podcasts.unsubscribe()">
@@ -836,6 +848,18 @@
<span>{{ t.player_podcast_subscribe }}</span>
</button>
</div>
<div class="podcast-share-status"
x-show="$store.podcasts.current.subscribed && $store.podcasts.share"
x-cloak
:class="{ pending: $store.podcasts.share && $store.podcasts.share.pending_confirmation }">
<span x-text="$store.podcasts.shareStatus()"></span>
<button class="podcast-share-review"
type="button"
x-show="$store.podcasts.share && $store.podcasts.share.pending_confirmation"
:disabled="$store.podcasts.sharing"
@click="$store.podcasts.reviewShare()">{{ t.player_podcast_share_review }}</button>
</div>
<div class="podcast-message error" x-show="$store.podcasts.shareError" x-cloak x-text="$store.podcasts.shareError"></div>
<div class="podcast-message" x-show="$store.podcasts.refreshMessage" x-cloak x-text="$store.podcasts.refreshMessage"></div>
<div class="podcast-message error" x-show="$store.podcasts.actionError" x-cloak x-text="$store.podcasts.actionError"></div>
</div>
+50
View File
@@ -7097,6 +7097,56 @@ button.user-stat:hover {
text-align: center;
}
.podcast-unsubscribed-label { color: var(--text-subdued); }
.podcast-shared-label { color: var(--accent); }
.podcast-share-toggle.active {
border-color: var(--accent);
color: var(--accent);
}
.podcast-share-status {
font-size: 12px;
color: var(--text-secondary);
margin: 6px 0 4px;
max-width: 720px;
line-height: 1.45;
}
.podcast-share-status.pending { color: #f0b84d; }
.podcast-share-review {
margin-left: 8px;
background: transparent;
border: 1px solid currentColor;
border-radius: 12px;
color: inherit;
cursor: pointer;
font: inherit;
padding: 1px 8px;
}
.podcast-share-dialog { max-width: 520px; }
.podcast-share-dialog p {
color: var(--text-secondary);
font-size: 13px;
line-height: 1.5;
margin: 8px 0;
}
.podcast-share-dialog .podcast-share-dialog-title {
color: var(--text-primary);
font-weight: 600;
}
.podcast-share-warnings {
color: #f0b84d;
font-size: 13px;
margin: 4px 0 8px 18px;
}
.podcast-share-url {
background: var(--bg-elevated);
border-radius: 6px;
color: var(--text-primary);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 12px;
margin: 4px 0;
padding: 6px 8px;
word-break: break-all;
}
.podcast-share-dialog .podcast-share-hint { color: var(--text-subdued); }
.podcast-header-info { min-width: 0; }
.podcast-description {
color: var(--text-secondary);