Show public podcasts in the federated search and subscribe from a card
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20bf30eae8
commit
59d94203db
6 files changed
+625
-5
No files matched your search
@@ -460,6 +460,19 @@ translations! {
|
|||||||
player_podcast_loading: "Preparing the episode…", "Готовим выпуск…";
|
player_podcast_loading: "Preparing the episode…", "Готовим выпуск…";
|
||||||
player_podcast_feed: "Feed", "Лента";
|
player_podcast_feed: "Feed", "Лента";
|
||||||
player_podcast_request_failed: "Request failed", "Запрос не выполнен";
|
player_podcast_request_failed: "Request failed", "Запрос не выполнен";
|
||||||
|
player_podcast_found_title: "Podcasts", "Подкасты";
|
||||||
|
player_podcast_type: "Podcast", "Подкаст";
|
||||||
|
player_podcast_found_subscribed: "Already subscribed", "Уже подписан";
|
||||||
|
player_podcast_found_open: "Open", "Открыть";
|
||||||
|
player_podcast_found_subscribing: "Subscribing…", "Подписываемся…";
|
||||||
|
player_podcast_found_done: "Subscribed. The subscription is private: only your devices see it.", "Вы подписались. Подписка приватная: её видят только ваши устройства.";
|
||||||
|
player_podcast_found_note: "This card was published by a federation member; its title, description and artwork are their claims. Subscribing reads the episodes from the feed below, never from the member, and your subscription stays private.", "Эту карточку опубликовал участник федерации; название, описание и обложка — его данные. При подписке выпуски загружаются из ленты по адресу ниже, а не у участника, и ваша подписка остаётся приватной.";
|
||||||
|
player_podcast_found_feed: "Feed URL", "Адрес ленты";
|
||||||
|
player_podcast_found_loading: "Loading seasons and episodes from the feed…", "Загружаем сезоны и выпуски из ленты…";
|
||||||
|
player_podcast_found_retry: "Try again", "Повторить";
|
||||||
|
player_podcast_found_latest: "Latest episode", "Последний выпуск";
|
||||||
|
player_podcast_found_more: "and {count} more", "и ещё {count}";
|
||||||
|
player_podcast_found_moved: "The feed has moved; subscribing follows it.", "Лента переехала; подписка последует за ней.";
|
||||||
player_shuffle: "Shuffle" , "Перемешать";
|
player_shuffle: "Shuffle" , "Перемешать";
|
||||||
player_repeat: "Repeat" , "Повтор";
|
player_repeat: "Repeat" , "Повтор";
|
||||||
player_volume: "Volume" , "Громкость";
|
player_volume: "Volume" , "Громкость";
|
||||||
|
|||||||
@@ -71,6 +71,85 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<!-- Podcast found in the federation: card, preview from its feed, subscribe -->
|
||||||
|
<template x-if="$store.podcasts.found">
|
||||||
|
<div class="modal-overlay" @click.self="$store.podcasts.closeFound()" @keydown.escape.window="$store.podcasts.closeFound()">
|
||||||
|
<div class="modal-box podcast-found-dialog" role="dialog" aria-modal="true" aria-labelledby="podcast-found-title">
|
||||||
|
<div class="podcast-found-head">
|
||||||
|
<div class="podcast-found-cover">
|
||||||
|
<template x-if="$store.podcasts.found.hit.image_url || $store.podcasts.found.preview?.image_url">
|
||||||
|
<img :src="$store.podcasts.found.hit.image_url || $store.podcasts.found.preview?.image_url" alt="" aria-hidden="true" referrerpolicy="no-referrer">
|
||||||
|
</template>
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0014 0M12 17v5M8 22h8"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="podcast-found-heading">
|
||||||
|
<div class="podcast-found-badges">
|
||||||
|
<span class="podcast-type-badge">{{ t.player_podcast_type }}</span>
|
||||||
|
<span class="podcast-subscribed-badge" x-show="$store.podcasts.found.subscribed">{{ t.player_podcast_found_subscribed }}</span>
|
||||||
|
</div>
|
||||||
|
<h3 id="podcast-found-title" x-text="$store.podcasts.found.hit.title"></h3>
|
||||||
|
<div class="podcast-found-author" x-show="$store.podcasts.found.hit.author" x-text="$store.podcasts.found.hit.author"></div>
|
||||||
|
<div class="podcast-found-meta" x-text="$store.podcasts.foundMeta($store.podcasts.found.hit)"></div>
|
||||||
|
<a class="podcast-found-link" x-show="$store.podcasts.found.hit.link"
|
||||||
|
:href="$store.podcasts.found.hit.link" target="_blank" rel="noopener noreferrer nofollow"
|
||||||
|
x-text="$store.podcasts.found.hit.link"></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="podcast-found-description" x-show="$store.podcasts.found.hit.description" x-text="$store.podcasts.found.hit.description"></p>
|
||||||
|
<div class="podcast-found-label">{{ t.player_podcast_found_feed }}</div>
|
||||||
|
<div class="podcast-share-url" x-text="$store.podcasts.found.hit.feed_url"></div>
|
||||||
|
<p class="podcast-share-hint">{{ t.player_podcast_found_note }}</p>
|
||||||
|
|
||||||
|
<div class="podcast-found-preview">
|
||||||
|
<template x-if="$store.podcasts.found.previewLoading">
|
||||||
|
<div class="podcast-found-status">{{ t.player_podcast_found_loading }}</div>
|
||||||
|
</template>
|
||||||
|
<template x-if="$store.podcasts.found.previewError">
|
||||||
|
<div class="podcast-found-status error">
|
||||||
|
<span x-text="$store.podcasts.found.previewError"></span>
|
||||||
|
<button class="modal-btn modal-btn-ghost" @click="$store.podcasts.loadFoundPreview()">{{ t.player_podcast_found_retry }}</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template x-if="$store.podcasts.found.preview">
|
||||||
|
<div>
|
||||||
|
<div class="podcast-found-status" x-show="$store.podcasts.found.preview.moved">{{ t.player_podcast_found_moved }}</div>
|
||||||
|
<div class="podcast-chips podcast-found-seasons">
|
||||||
|
<template x-for="season in $store.podcasts.found.preview.seasons" :key="$store.podcasts.seasonValue(season)">
|
||||||
|
<span class="podcast-chip" x-text="`${$store.podcasts.seasonLabel(season)} · ${season.episode_count}`"></span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<ul class="podcast-found-episodes">
|
||||||
|
<template x-for="(episode, index) in $store.podcasts.found.preview.episodes" :key="index">
|
||||||
|
<li>
|
||||||
|
<div class="podcast-found-episode-title" x-text="episode.title"></div>
|
||||||
|
<div class="podcast-found-episode-meta" x-text="$store.podcasts.episodeMeta(episode)"></div>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
</ul>
|
||||||
|
<div class="podcast-found-status" x-show="$store.podcasts.foundMore($store.podcasts.found.preview)" x-text="$store.podcasts.foundMore($store.podcasts.found.preview)"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="podcast-found-status error" x-show="$store.podcasts.found.error" x-text="$store.podcasts.found.error"></div>
|
||||||
|
<div class="podcast-found-status" x-show="$store.podcasts.found.message" x-text="$store.podcasts.found.message"></div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="modal-btn modal-btn-ghost" @click="$store.podcasts.closeFound()">{{ t.player_close }}</button>
|
||||||
|
<template x-if="$store.podcasts.found.subscribed">
|
||||||
|
<button class="modal-btn modal-btn-primary" @click="$store.podcasts.openFoundPodcast()">{{ t.player_podcast_found_open }}</button>
|
||||||
|
</template>
|
||||||
|
<template x-if="!$store.podcasts.found.subscribed">
|
||||||
|
<button class="modal-btn modal-btn-primary" :disabled="$store.podcasts.found.subscribing"
|
||||||
|
@click="$store.podcasts.subscribeFound()"
|
||||||
|
x-text="$store.podcasts.foundButtonLabel()"></button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
<!-- Create / Rename Playlist Modal -->
|
<!-- Create / Rename Playlist Modal -->
|
||||||
<template x-if="$store.playlists.modal">
|
<template x-if="$store.playlists.modal">
|
||||||
<div class="modal-overlay" @click.self="$store.playlists.modal = null">
|
<div class="modal-overlay" @click.self="$store.playlists.modal = null">
|
||||||
|
|||||||
@@ -94,6 +94,12 @@ const T = {
|
|||||||
podcastSourceFailed: "{{ t.player_podcast_source_failed }}",
|
podcastSourceFailed: "{{ t.player_podcast_source_failed }}",
|
||||||
podcastCannotSeek: "{{ t.player_podcast_cannot_seek }}",
|
podcastCannotSeek: "{{ t.player_podcast_cannot_seek }}",
|
||||||
podcastRequestFailed: "{{ t.player_podcast_request_failed }}",
|
podcastRequestFailed: "{{ t.player_podcast_request_failed }}",
|
||||||
|
podcastType: "{{ t.player_podcast_type }}",
|
||||||
|
podcastFoundLatest: "{{ t.player_podcast_found_latest }}",
|
||||||
|
podcastFoundMore: "{{ t.player_podcast_found_more }}",
|
||||||
|
podcastFoundDone: "{{ t.player_podcast_found_done }}",
|
||||||
|
podcastFoundSubscribing: "{{ t.player_podcast_found_subscribing }}",
|
||||||
|
podcastSubscribe: "{{ t.player_podcast_subscribe }}",
|
||||||
podcastEpisodes: "{{ t.player_podcast_episodes }}",
|
podcastEpisodes: "{{ t.player_podcast_episodes }}",
|
||||||
podcastUnplayed: "{{ t.player_podcast_unplayed }}",
|
podcastUnplayed: "{{ t.player_podcast_unplayed }}",
|
||||||
podcastSeasons: "{{ t.player_podcast_seasons }}",
|
podcastSeasons: "{{ t.player_podcast_seasons }}",
|
||||||
@@ -3692,6 +3698,8 @@ document.addEventListener('alpine:init', () => {
|
|||||||
sharing: false,
|
sharing: false,
|
||||||
shareError: '',
|
shareError: '',
|
||||||
shareDialog: null,
|
shareDialog: null,
|
||||||
|
found: null,
|
||||||
|
_foundToken: 0,
|
||||||
busy: {},
|
busy: {},
|
||||||
expanded: {},
|
expanded: {},
|
||||||
_searchTimer: null,
|
_searchTimer: null,
|
||||||
@@ -3979,6 +3987,171 @@ document.addEventListener('alpine:init', () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Public podcasts found by the federated search. A card is another
|
||||||
|
// member's claim: only expected fields of expected types are kept,
|
||||||
|
// URLs must be absolute http(s) (artwork: https only), and every
|
||||||
|
// text is rendered with x-text.
|
||||||
|
safeHttpUrl(value) {
|
||||||
|
if (typeof value !== 'string' || !value || value.length > 2048) return '';
|
||||||
|
let url;
|
||||||
|
try { url = new URL(value); } catch { return ''; }
|
||||||
|
if (url.protocol !== 'http:' && url.protocol !== 'https:') return '';
|
||||||
|
if (url.username || url.password || !url.hostname) return '';
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
safeImageUrl(value) {
|
||||||
|
const url = this.safeHttpUrl(value);
|
||||||
|
return url && url.startsWith('https:') ? url : '';
|
||||||
|
},
|
||||||
|
|
||||||
|
foundHit(entity) {
|
||||||
|
if (!entity || typeof entity !== 'object' || entity.type !== 'podcast') return null;
|
||||||
|
const text = (value, max) => (typeof value === 'string' ? value.slice(0, max) : '');
|
||||||
|
const count = value => (Number.isInteger(value) && value >= 0 ? value : null);
|
||||||
|
const podcastId = text(entity.podcast_id, 200);
|
||||||
|
const feedUrl = this.safeHttpUrl(entity.feed_url);
|
||||||
|
const title = text(entity.title, 300).trim();
|
||||||
|
if (!/^pod1:[a-z2-7]{52}$/.test(podcastId) || !feedUrl || !title) return null;
|
||||||
|
const localId = text(entity.local_podcast_id, 200);
|
||||||
|
return {
|
||||||
|
type: 'podcast',
|
||||||
|
podcast_id: podcastId,
|
||||||
|
feed_url: feedUrl,
|
||||||
|
title,
|
||||||
|
author: text(entity.author, 300),
|
||||||
|
description: text(entity.description, 1000),
|
||||||
|
image_url: this.safeImageUrl(entity.image_url),
|
||||||
|
link: this.safeHttpUrl(entity.link),
|
||||||
|
language: text(entity.language, 35),
|
||||||
|
categories: Array.isArray(entity.categories)
|
||||||
|
? entity.categories.filter(item => typeof item === 'string').slice(0, 8).map(item => item.slice(0, 64))
|
||||||
|
: [],
|
||||||
|
episode_count: count(entity.episode_count),
|
||||||
|
latest_episode_at_ms: count(entity.latest_episode_at_ms),
|
||||||
|
publisher_count: count(entity.publisher_count) || 0,
|
||||||
|
rank: count(entity.rank) ?? Number.MAX_SAFE_INTEGER,
|
||||||
|
exact_match: entity.exact_match === true,
|
||||||
|
subscribed: entity.subscribed === true,
|
||||||
|
local_podcast_id: /^pod1:[a-z2-7]{52}$/.test(localId) ? localId : null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
foundMeta(hit) {
|
||||||
|
if (!hit) return '';
|
||||||
|
const parts = [];
|
||||||
|
if (hit.episode_count != null) parts.push(`${hit.episode_count} ${T.podcastEpisodes}`);
|
||||||
|
if (hit.latest_episode_at_ms) parts.push(`${T.podcastFoundLatest}: ${this.formatDate(hit.latest_episode_at_ms)}`);
|
||||||
|
if (hit.language) parts.push(hit.language);
|
||||||
|
if (hit.categories?.length) parts.push(hit.categories.join(', '));
|
||||||
|
return parts.join(' · ');
|
||||||
|
},
|
||||||
|
|
||||||
|
foundSubtitle(hit) {
|
||||||
|
if (!hit) return '';
|
||||||
|
return [hit.author, hit.episode_count != null ? `${hit.episode_count} ${T.podcastEpisodes}` : '']
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ');
|
||||||
|
},
|
||||||
|
|
||||||
|
foundMore(preview) {
|
||||||
|
const more = Number(preview?.episode_count || 0) - (preview?.episodes?.length || 0);
|
||||||
|
return more > 0 ? T.podcastFoundMore.replace('{count}', String(more)) : '';
|
||||||
|
},
|
||||||
|
|
||||||
|
openFound(hit) {
|
||||||
|
if (GUEST || !hit?.podcast_id || !hit.feed_url) return;
|
||||||
|
this._foundToken += 1;
|
||||||
|
this.found = {
|
||||||
|
hit,
|
||||||
|
preview: null,
|
||||||
|
previewLoading: false,
|
||||||
|
previewError: '',
|
||||||
|
subscribing: false,
|
||||||
|
error: '',
|
||||||
|
message: '',
|
||||||
|
subscribed: hit.subscribed === true,
|
||||||
|
localPodcastId: hit.local_podcast_id || null,
|
||||||
|
};
|
||||||
|
this.loadFoundPreview();
|
||||||
|
},
|
||||||
|
|
||||||
|
closeFound() {
|
||||||
|
this._foundToken += 1;
|
||||||
|
this.found = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
_foundBody(hit) {
|
||||||
|
// The card's id and origin URL, exactly as found: the server
|
||||||
|
// checks that the id comes from this URL.
|
||||||
|
return {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ podcast_id: hit.podcast_id, feed_url: hit.feed_url }),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
async loadFoundPreview() {
|
||||||
|
const found = this.found;
|
||||||
|
if (!found || found.previewLoading) return;
|
||||||
|
const token = this._foundToken;
|
||||||
|
this.found = { ...found, previewLoading: true, previewError: '' };
|
||||||
|
try {
|
||||||
|
const preview = await this._json('/api/podcasts/discovery/preview', this._foundBody(found.hit));
|
||||||
|
if (token !== this._foundToken) return;
|
||||||
|
this.found = {
|
||||||
|
...this.found,
|
||||||
|
preview: {
|
||||||
|
...preview,
|
||||||
|
image_url: this.safeImageUrl(preview?.image_url),
|
||||||
|
link: this.safeHttpUrl(preview?.link),
|
||||||
|
seasons: Array.isArray(preview?.seasons) ? preview.seasons : [],
|
||||||
|
episodes: Array.isArray(preview?.episodes) ? preview.episodes : [],
|
||||||
|
},
|
||||||
|
previewLoading: false,
|
||||||
|
subscribed: this.found.subscribed || preview?.subscribed === true,
|
||||||
|
localPodcastId: this.found.localPodcastId || preview?.local_podcast_id || null,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
if (token !== this._foundToken) return;
|
||||||
|
this.found = { ...this.found, previewLoading: false, previewError: error.message };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async subscribeFound() {
|
||||||
|
const found = this.found;
|
||||||
|
if (!found || found.subscribing || found.subscribed) return;
|
||||||
|
const token = this._foundToken;
|
||||||
|
this.found = { ...found, subscribing: true, error: '', message: '' };
|
||||||
|
try {
|
||||||
|
const data = await this._json('/api/podcasts/discovery/subscribe', this._foundBody(found.hit));
|
||||||
|
const podcastId = data?.podcast?.podcast_id || found.hit.podcast_id;
|
||||||
|
Alpine.store('library')?.markFoundPodcastSubscribed?.(found.hit.podcast_id, podcastId);
|
||||||
|
this.loadList();
|
||||||
|
if (token !== this._foundToken) return;
|
||||||
|
this.found = {
|
||||||
|
...this.found,
|
||||||
|
subscribing: false,
|
||||||
|
subscribed: true,
|
||||||
|
localPodcastId: podcastId,
|
||||||
|
message: data?.already_subscribed ? T.podcastAlready : T.podcastFoundDone,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
if (token !== this._foundToken) return;
|
||||||
|
this.found = { ...this.found, subscribing: false, error: error.message };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
foundButtonLabel() {
|
||||||
|
return this.found?.subscribing ? T.podcastFoundSubscribing : T.podcastSubscribe;
|
||||||
|
},
|
||||||
|
|
||||||
|
openFoundPodcast() {
|
||||||
|
const podcastId = this.found?.localPodcastId || this.found?.hit?.podcast_id;
|
||||||
|
this.closeFound();
|
||||||
|
if (podcastId) this.open(podcastId);
|
||||||
|
},
|
||||||
|
|
||||||
jamBlocked() {
|
jamBlocked() {
|
||||||
// A Jam guest controls the host's queue: episodes are private.
|
// A Jam guest controls the host's queue: episodes are private.
|
||||||
return !!Alpine.store('devices')?.isControllingRemoteJam?.();
|
return !!Alpine.store('devices')?.isControllingRemoteJam?.();
|
||||||
@@ -4172,7 +4345,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
similaritySearchLabel: '',
|
similaritySearchLabel: '',
|
||||||
similaritySearchError: '',
|
similaritySearchError: '',
|
||||||
similaritySearchStats: { loading: false, tracks: 0, artists: 0, peers: 0, elapsed_ms: 0 },
|
similaritySearchStats: { loading: false, tracks: 0, artists: 0, peers: 0, elapsed_ms: 0 },
|
||||||
federationSearch: { loading: false, error: '', artists: [], releases: [], tracks: [] },
|
federationSearch: { loading: false, error: '', artists: [], releases: [], tracks: [], podcasts: [] },
|
||||||
artistFederation: { loading: false, error: '', releases: [], tracks: [] },
|
artistFederation: { loading: false, error: '', releases: [], tracks: [] },
|
||||||
federationPreparing: {},
|
federationPreparing: {},
|
||||||
federationFailures: {},
|
federationFailures: {},
|
||||||
@@ -5112,7 +5285,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.similaritySearchError = '';
|
this.similaritySearchError = '';
|
||||||
this.searchLoading = true;
|
this.searchLoading = true;
|
||||||
this.searchResults = null;
|
this.searchResults = null;
|
||||||
this.federationSearch = { loading: true, error: '', artists: [], releases: [], tracks: [] };
|
this.federationSearch = { loading: true, error: '', artists: [], releases: [], tracks: [], podcasts: [] };
|
||||||
this.similaritySearchStats = { loading: true, tracks: 0, artists: 0, peers: 0, elapsed_ms: 0 };
|
this.similaritySearchStats = { loading: true, tracks: 0, artists: 0, peers: 0, elapsed_ms: 0 };
|
||||||
Alpine.store('info').close();
|
Alpine.store('info').close();
|
||||||
try {
|
try {
|
||||||
@@ -5254,12 +5427,12 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this._federationSearchSource.close();
|
this._federationSearchSource.close();
|
||||||
this._federationSearchSource = null;
|
this._federationSearchSource = null;
|
||||||
}
|
}
|
||||||
this.federationSearch = { loading: false, error: '', artists: [], releases: [], tracks: [] };
|
this.federationSearch = { loading: false, error: '', artists: [], releases: [], tracks: [], podcasts: [] };
|
||||||
},
|
},
|
||||||
|
|
||||||
startFederationSearch(query) {
|
startFederationSearch(query) {
|
||||||
this.stopFederationSearch();
|
this.stopFederationSearch();
|
||||||
this.federationSearch = { loading: true, error: '', artists: [], releases: [], tracks: [] };
|
this.federationSearch = { loading: true, error: '', artists: [], releases: [], tracks: [], podcasts: [] };
|
||||||
const source = new EventSource(`/api/player/federation/search/events?q=${encodeURIComponent(query)}`);
|
const source = new EventSource(`/api/player/federation/search/events?q=${encodeURIComponent(query)}`);
|
||||||
this._federationSearchSource = source;
|
this._federationSearchSource = source;
|
||||||
const updateResults = (kind, keyFor, labelFor, entity) => {
|
const updateResults = (kind, keyFor, labelFor, entity) => {
|
||||||
@@ -5312,6 +5485,20 @@ document.addEventListener('alpine:init', () => {
|
|||||||
if (!release?.key) return;
|
if (!release?.key) return;
|
||||||
updateResults('releases', item => JSON.stringify(item.key || {}), item => item.title, release);
|
updateResults('releases', item => JSON.stringify(item.key || {}), item => item.title, release);
|
||||||
});
|
});
|
||||||
|
source.addEventListener('federation.podcast', event => {
|
||||||
|
if (this._federationSearchSource !== source) return;
|
||||||
|
let payload = null;
|
||||||
|
try { payload = JSON.parse(event.data); } catch { return; }
|
||||||
|
// Public podcast cards: typed, sanitized, ordered by their
|
||||||
|
// place among the music results.
|
||||||
|
const hit = Alpine.store('podcasts')?.foundHit?.(payload?.entity);
|
||||||
|
if (!hit) return;
|
||||||
|
const podcasts = (this.federationSearch.podcasts || [])
|
||||||
|
.filter(item => item.podcast_id !== hit.podcast_id);
|
||||||
|
podcasts.push(hit);
|
||||||
|
podcasts.sort((left, right) => left.rank - right.rank);
|
||||||
|
this.federationSearch = { ...this.federationSearch, podcasts };
|
||||||
|
});
|
||||||
source.addEventListener('search.completed', () => {
|
source.addEventListener('search.completed', () => {
|
||||||
window.clearTimeout(watchdog);
|
window.clearTimeout(watchdog);
|
||||||
if (this._federationSearchSource === source) {
|
if (this._federationSearchSource === source) {
|
||||||
@@ -5345,6 +5532,15 @@ document.addEventListener('alpine:init', () => {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
markFoundPodcastSubscribed(podcastId, localPodcastId) {
|
||||||
|
const podcasts = (this.federationSearch?.podcasts || []).map(item => (
|
||||||
|
item.podcast_id === podcastId
|
||||||
|
? { ...item, subscribed: true, local_podcast_id: localPodcastId || item.local_podcast_id }
|
||||||
|
: item
|
||||||
|
));
|
||||||
|
this.federationSearch = { ...this.federationSearch, podcasts };
|
||||||
|
},
|
||||||
|
|
||||||
normalizeFederationSearchText(value) {
|
normalizeFederationSearchText(value) {
|
||||||
return String(value || '')
|
return String(value || '')
|
||||||
.normalize('NFKD')
|
.normalize('NFKD')
|
||||||
|
|||||||
@@ -625,6 +625,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="search-podcasts-section"
|
||||||
|
x-show="!$store.library.similaritySearchLabel && ($store.library.federationSearch.podcasts || []).length > 0"
|
||||||
|
x-cloak>
|
||||||
|
<h3 class="search-subsection-title">{{ t.player_podcast_found_title }}</h3>
|
||||||
|
<div class="search-releases-row">
|
||||||
|
<template x-for="hit in ($store.library.federationSearch.podcasts || [])"
|
||||||
|
:key="hit.podcast_id">
|
||||||
|
<div class="search-release-card federation-entity-card podcast-found-card"
|
||||||
|
role="button" tabindex="0"
|
||||||
|
@click="$store.podcasts.openFound(hit)"
|
||||||
|
@keydown.enter="$store.podcasts.openFound(hit)">
|
||||||
|
<div class="search-release-cover">
|
||||||
|
<template x-if="hit.image_url">
|
||||||
|
<img class="artwork-image" :src="hit.image_url" alt="" aria-hidden="true"
|
||||||
|
loading="lazy" referrerpolicy="no-referrer"
|
||||||
|
@load="$event.currentTarget.classList.add('artwork-loaded')"
|
||||||
|
@error="$event.currentTarget.classList.remove('artwork-loaded')">
|
||||||
|
</template>
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||||
|
<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M5 10a7 7 0 0014 0M12 17v5M8 22h8"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<div class="podcast-found-badges">
|
||||||
|
<span class="podcast-type-badge">{{ t.player_podcast_type }}</span>
|
||||||
|
<span class="podcast-subscribed-badge" x-show="hit.subscribed">{{ t.player_podcast_found_subscribed }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-title" x-text="hit.title"></div>
|
||||||
|
<div class="card-subtitle" x-text="$store.podcasts.foundSubtitle(hit)"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<template x-for="(track, idx) in $store.library.federationSearch.tracks"
|
<template x-for="(track, idx) in $store.library.federationSearch.tracks"
|
||||||
:key="track.key.content_id">
|
:key="track.key.content_id">
|
||||||
<div class="track-row federation-track-row"
|
<div class="track-row federation-track-row"
|
||||||
|
|||||||
@@ -7121,6 +7121,124 @@ button.user-stat:hover {
|
|||||||
padding: 1px 8px;
|
padding: 1px 8px;
|
||||||
}
|
}
|
||||||
.podcast-share-dialog { max-width: 520px; }
|
.podcast-share-dialog { max-width: 520px; }
|
||||||
|
.search-podcasts-section { margin: 4px 0 18px; }
|
||||||
|
.search-subsection-title {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
margin: 0 0 8px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
.podcast-found-badges {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
.podcast-type-badge,
|
||||||
|
.podcast-subscribed-badge {
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.6;
|
||||||
|
padding: 0 6px;
|
||||||
|
}
|
||||||
|
.podcast-type-badge { background: var(--bg-active); color: var(--text-secondary); }
|
||||||
|
.podcast-subscribed-badge { background: var(--accent); color: #000; }
|
||||||
|
.podcast-found-dialog {
|
||||||
|
max-width: 600px;
|
||||||
|
max-height: calc(100vh - 48px);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.podcast-found-head {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
.podcast-found-cover {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 96px;
|
||||||
|
width: 96px;
|
||||||
|
height: 96px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--bg-elevated);
|
||||||
|
overflow: hidden;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.podcast-found-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
||||||
|
.podcast-found-cover svg { width: 36px; height: 36px; color: var(--text-subdued); }
|
||||||
|
.podcast-found-heading { min-width: 0; }
|
||||||
|
.podcast-found-heading h3 { margin: 2px 0 4px; overflow-wrap: anywhere; }
|
||||||
|
.podcast-found-author,
|
||||||
|
.podcast-found-meta {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.podcast-found-link {
|
||||||
|
color: var(--accent);
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.podcast-found-description {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin: 12px 0;
|
||||||
|
white-space: pre-line;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.podcast-found-label {
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
.podcast-found-dialog .podcast-share-hint {
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.podcast-found-preview { margin: 8px 0; }
|
||||||
|
.podcast-found-seasons { margin: 8px 0; }
|
||||||
|
.podcast-found-seasons .podcast-chip { cursor: default; }
|
||||||
|
.podcast-found-status {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: 13px;
|
||||||
|
margin: 6px 0;
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.podcast-found-status.error { color: #ff6b6b; }
|
||||||
|
.podcast-found-episodes {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
max-height: 240px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
.podcast-found-episodes li {
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
padding: 6px 2px;
|
||||||
|
}
|
||||||
|
.podcast-found-episode-title {
|
||||||
|
font-size: 13px;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
.podcast-found-episode-meta {
|
||||||
|
color: var(--text-subdued);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.podcast-found-head { flex-direction: column; }
|
||||||
|
}
|
||||||
.podcast-share-dialog p {
|
.podcast-share-dialog p {
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|||||||
@@ -799,7 +799,7 @@ function podcastsStore(stores = {}, overrides = {}) {
|
|||||||
podcastFetchError: 'Last check failed', podcastLastChecked: 'Checked', podcastNeverChecked: 'Not checked yet',
|
podcastFetchError: 'Last check failed', podcastLastChecked: 'Checked', podcastNeverChecked: 'Not checked yet',
|
||||||
podcastJamBlocked: 'jam blocked', podcastRequestFailed: 'request failed',
|
podcastJamBlocked: 'jam blocked', podcastRequestFailed: 'request failed',
|
||||||
},
|
},
|
||||||
URLSearchParams, GUEST: false,
|
URLSearchParams, URL, GUEST: false,
|
||||||
fetch: async (url, init = {}) => {
|
fetch: async (url, init = {}) => {
|
||||||
calls.push({url, init});
|
calls.push({url, init});
|
||||||
if (overrides.respond) return overrides.respond(url, init);
|
if (overrides.respond) return overrides.respond(url, init);
|
||||||
@@ -1100,3 +1100,185 @@ test('Play after a failed source waits for the final report and resumes where th
|
|||||||
await flush();
|
await flush();
|
||||||
assert.deepEqual(other.calls.map(call => call.url.split('/').pop()), ['playback', 'progress']);
|
assert.deepEqual(other.calls.map(call => call.url.split('/').pop()), ['playback', 'progress']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Public podcasts in the federated search
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const POD_A = 'pod1:' + 'a'.repeat(52);
|
||||||
|
const POD_B = 'pod1:' + 'b'.repeat(52);
|
||||||
|
const POD_LOCAL = 'pod1:' + 'c'.repeat(52);
|
||||||
|
|
||||||
|
function foundEntity(extra = {}) {
|
||||||
|
return Object.assign({
|
||||||
|
type: 'podcast', kind: 'podcast', podcast_id: POD_A,
|
||||||
|
feed_url: 'https://feeds.example/show.xml?utm=x', title: 'Night Radio', author: 'Host',
|
||||||
|
description: '<img src=x onerror=alert(1)>', image_url: 'https://cdn.example/art.jpg',
|
||||||
|
link: 'https://show.example/', language: 'en', categories: ['Technology', 7],
|
||||||
|
episode_count: 12, latest_episode_at_ms: 1700000000000, publisher_count: 2,
|
||||||
|
rank: 1, exact_match: true, subscribed: false, local_podcast_id: null,
|
||||||
|
}, extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
const FOUND_T = {
|
||||||
|
podcastFoundLatest: 'Latest', podcastFoundMore: 'and {count} more', podcastFoundDone: 'subscribed, private',
|
||||||
|
podcastAlready: 'already', podcastFoundSubscribing: 'subscribing', podcastSubscribe: 'Subscribe',
|
||||||
|
};
|
||||||
|
|
||||||
|
test('podcast cards from the search keep only typed fields and safe URLs', () => {
|
||||||
|
const {store} = podcastsStore({}, {T: FOUND_T});
|
||||||
|
const hit = store.foundHit(foundEntity());
|
||||||
|
// The feed URL is passed on exactly as found (the server hashes it).
|
||||||
|
assert.equal(hit.feed_url, 'https://feeds.example/show.xml?utm=x');
|
||||||
|
assert.equal(hit.description, '<img src=x onerror=alert(1)>', 'text stays text (x-text)');
|
||||||
|
assert.deepEqual(Array.from(hit.categories), ['Technology']);
|
||||||
|
assert.equal(hit.image_url, 'https://cdn.example/art.jpg');
|
||||||
|
assert.equal(store.foundMeta(hit).startsWith('12 episodes · Latest: '), true);
|
||||||
|
assert.equal(store.foundSubtitle(hit), 'Host · 12 episodes');
|
||||||
|
|
||||||
|
const unsafe = store.foundHit(foundEntity({
|
||||||
|
link: 'javascript:alert(1)', image_url: 'http://cdn.example/art.jpg',
|
||||||
|
local_podcast_id: 'javascript:x', rank: 'first', subscribed: 'yes',
|
||||||
|
}));
|
||||||
|
assert.equal(unsafe.link, '');
|
||||||
|
assert.equal(unsafe.image_url, '', 'artwork only over https');
|
||||||
|
assert.equal(unsafe.local_podcast_id, null);
|
||||||
|
assert.equal(unsafe.rank, Number.MAX_SAFE_INTEGER);
|
||||||
|
assert.equal(unsafe.subscribed, false);
|
||||||
|
assert.equal(store.foundHit(foundEntity({link: 'https://user:pw@show.example/'})).link, '');
|
||||||
|
|
||||||
|
for (const bad of [
|
||||||
|
foundEntity({type: 'music'}), foundEntity({podcast_id: 'pod1:x'}), foundEntity({feed_url: 'javascript:alert(1)'}),
|
||||||
|
foundEntity({feed_url: 'ftp://feeds.example/show.xml'}), foundEntity({title: ' '}), null, 'podcast',
|
||||||
|
]) {
|
||||||
|
assert.equal(store.foundHit(bad), null, JSON.stringify(bad));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the federated search shows podcast cards next to music, ordered by rank', () => {
|
||||||
|
const podcasts = podcastsStore({}, {T: FOUND_T}).store;
|
||||||
|
const sources = [];
|
||||||
|
class FakeEventSource {
|
||||||
|
constructor(url) { this.url = url; this.listeners = {}; sources.push(this); }
|
||||||
|
addEventListener(name, listener) { this.listeners[name] = listener; }
|
||||||
|
emit(name, data) { this.listeners[name]({data: JSON.stringify(data)}); }
|
||||||
|
close() { this.closed = true; }
|
||||||
|
}
|
||||||
|
const context = vm.createContext({
|
||||||
|
EventSource: FakeEventSource, encodeURIComponent,
|
||||||
|
window: {setTimeout: () => 1, clearTimeout: () => {}},
|
||||||
|
Alpine: {store: name => (name === 'podcasts' ? podcasts : null)},
|
||||||
|
});
|
||||||
|
vm.runInContext(`this.library = {
|
||||||
|
federationSearch: null, _federationSearchSource: null,
|
||||||
|
federationSearchScore() { return 0; },
|
||||||
|
withTrackAvailability(track) { return track; },
|
||||||
|
withFederationArtistFallback(artist) { return artist; },
|
||||||
|
hydrateFederationSearchRelease(release) { return release; },
|
||||||
|
${method('stopFederationSearch')}
|
||||||
|
${method('startFederationSearch')}
|
||||||
|
${method('markFoundPodcastSubscribed')}
|
||||||
|
};`, context);
|
||||||
|
const library = context.library;
|
||||||
|
library.startFederationSearch('night radio');
|
||||||
|
const source = sources[0];
|
||||||
|
assert.equal(source.url, '/api/player/federation/search/events?q=night%20radio');
|
||||||
|
assert.deepEqual(Array.from(library.federationSearch.podcasts), []);
|
||||||
|
|
||||||
|
// Music events are handled as before.
|
||||||
|
source.emit('federation.track', {type: 'music', kind: 'federation.track', entity: {key: {content_id: 'b3:1'}, metadata: {title: 'Theme'}}});
|
||||||
|
source.emit('federation.podcast', {type: 'podcast', kind: 'federation.podcast', entity: foundEntity({podcast_id: POD_B, title: 'Night Radio Talks', rank: 3})});
|
||||||
|
source.emit('federation.podcast', {type: 'podcast', kind: 'federation.podcast', entity: foundEntity({rank: 1, subscribed: true, local_podcast_id: POD_LOCAL})});
|
||||||
|
// Not a podcast card: ignored.
|
||||||
|
source.emit('federation.podcast', {entity: {type: 'music', podcast_id: POD_A}});
|
||||||
|
// The same podcast again replaces its card.
|
||||||
|
source.emit('federation.podcast', {entity: foundEntity({podcast_id: POD_B, title: 'Night Radio Talks', rank: 3, author: 'New host'})});
|
||||||
|
|
||||||
|
assert.equal(library.federationSearch.tracks.length, 1);
|
||||||
|
const ids = Array.from(library.federationSearch.podcasts, hit => hit.podcast_id);
|
||||||
|
assert.deepEqual(ids, [POD_A, POD_B]);
|
||||||
|
assert.equal(library.federationSearch.podcasts[0].subscribed, true);
|
||||||
|
assert.equal(library.federationSearch.podcasts[1].author, 'New host');
|
||||||
|
|
||||||
|
library.markFoundPodcastSubscribed(POD_B, POD_B);
|
||||||
|
assert.equal(library.federationSearch.podcasts[1].subscribed, true);
|
||||||
|
assert.equal(library.federationSearch.podcasts[1].local_podcast_id, POD_B);
|
||||||
|
|
||||||
|
source.emit('search.completed', {entity: {partial: false, podcast_discovery: 'running'}});
|
||||||
|
assert.equal(library.federationSearch.loading, false);
|
||||||
|
assert.equal(source.closed, true);
|
||||||
|
// Events of a closed search change nothing.
|
||||||
|
library.startFederationSearch('other');
|
||||||
|
source.emit('federation.podcast', {entity: foundEntity()});
|
||||||
|
assert.deepEqual(Array.from(library.federationSearch.podcasts), []);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a found podcast is previewed, then subscribed with the card id and origin URL', async () => {
|
||||||
|
const answers = [];
|
||||||
|
const marked = [];
|
||||||
|
const library = {markFoundPodcastSubscribed: (id, local) => marked.push([id, local])};
|
||||||
|
const {store, calls} = podcastsStore({library}, {T: FOUND_T, respond: async () => answers.shift()});
|
||||||
|
let listLoads = 0;
|
||||||
|
store.loadList = () => { listLoads += 1; };
|
||||||
|
const opened = [];
|
||||||
|
store.open = id => opened.push(id);
|
||||||
|
const hit = store.foundHit(foundEntity());
|
||||||
|
|
||||||
|
answers.push({ok: true, status: 200, json: async () => ({
|
||||||
|
podcast_id: POD_A, feed_url: hit.feed_url, moved: false, title: 'Night Radio',
|
||||||
|
link: 'javascript:alert(1)', image_url: 'https://cdn.example/feed.jpg', episode_count: 60,
|
||||||
|
seasons: [{season: 1, episode_count: 59}, {season: null, episode_count: 1}],
|
||||||
|
episodes: [{title: 'Newest', season: 1, episode_number: 59, duration_ms: 60000}],
|
||||||
|
subscribed: false, local_podcast_id: null,
|
||||||
|
})});
|
||||||
|
store.openFound(hit);
|
||||||
|
assert.equal(store.found.previewLoading, true);
|
||||||
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
|
assert.equal(calls[0].url, '/api/podcasts/discovery/preview');
|
||||||
|
assert.equal(calls[0].init.method, 'POST');
|
||||||
|
assert.equal(calls[0].init.headers['Content-Type'], 'application/json');
|
||||||
|
assert.deepEqual(JSON.parse(calls[0].init.body), {podcast_id: POD_A, feed_url: 'https://feeds.example/show.xml?utm=x'});
|
||||||
|
assert.equal(store.found.previewLoading, false);
|
||||||
|
assert.equal(store.found.preview.link, '', 'feed links are checked too');
|
||||||
|
assert.equal(store.found.preview.episodes[0].title, 'Newest');
|
||||||
|
assert.equal(store.foundMore(store.found.preview), 'and 59 more');
|
||||||
|
assert.equal(store.foundButtonLabel(), 'Subscribe');
|
||||||
|
|
||||||
|
// Subscribing: the account already knew the feed under another id.
|
||||||
|
answers.push({ok: true, status: 200, json: async () => ({podcast: {podcast_id: POD_LOCAL}, already_subscribed: false, new_episodes: 60})});
|
||||||
|
const pending = store.subscribeFound();
|
||||||
|
assert.equal(store.foundButtonLabel(), 'subscribing');
|
||||||
|
await pending;
|
||||||
|
assert.equal(calls[1].url, '/api/podcasts/discovery/subscribe');
|
||||||
|
assert.deepEqual(JSON.parse(calls[1].init.body), {podcast_id: POD_A, feed_url: 'https://feeds.example/show.xml?utm=x'});
|
||||||
|
assert.deepEqual(marked, [[POD_A, POD_LOCAL]]);
|
||||||
|
assert.equal(listLoads, 1);
|
||||||
|
assert.equal(store.found.subscribed, true);
|
||||||
|
assert.equal(store.found.message, 'subscribed, private');
|
||||||
|
// Subscribed: the button opens the account's podcast; no second request.
|
||||||
|
await store.subscribeFound();
|
||||||
|
assert.equal(calls.length, 2);
|
||||||
|
store.openFoundPodcast();
|
||||||
|
assert.equal(store.found, null);
|
||||||
|
assert.deepEqual(opened, [POD_LOCAL]);
|
||||||
|
|
||||||
|
// An already subscribed card opens directly; a failure is shown.
|
||||||
|
answers.push({ok: true, status: 200, json: async () => ({podcast_id: POD_A, seasons: [], episodes: [], episode_count: 0})});
|
||||||
|
store.openFound(store.foundHit(foundEntity({subscribed: true, local_podcast_id: POD_LOCAL})));
|
||||||
|
assert.equal(store.found.subscribed, true);
|
||||||
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
|
store.found.subscribed = false;
|
||||||
|
answers.push({ok: false, status: 502, json: async () => ({error: 'the feed could not be loaded: timeout'})});
|
||||||
|
await store.subscribeFound();
|
||||||
|
assert.equal(store.found.error, 'the feed could not be loaded: timeout');
|
||||||
|
assert.equal(store.found.subscribing, false);
|
||||||
|
|
||||||
|
// Closing during the preview drops its late answer.
|
||||||
|
let release;
|
||||||
|
answers.push(new Promise(resolve => { release = resolve; }));
|
||||||
|
store.openFound(hit);
|
||||||
|
store.closeFound();
|
||||||
|
release({ok: true, status: 200, json: async () => ({title: 'late'})});
|
||||||
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
|
assert.equal(store.found, null);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user