Commit bf4ae9ed authored by David Trattnig's avatar David Trattnig
Browse files

Refact: Load hosts in one request with show

parent e6f8b3c0
Pipeline #1998 passed with stages
in 8 minutes and 3 seconds
let OFFLINE_URL = "/offline.html"; // Match your offline page URL
let PRE_CACHE = "pre-cache-v3"; // Manually update version or generate one server-site
let PRE_CACHE = "pre-cache-v4"; // Manually update version or generate one server-site
let PRE_CACHE_URL = "/pre-cache.json" // Match your pre-cache URL
let RUNTIME_CACHE = "runtime-cache";
......
......@@ -5,7 +5,6 @@
export let api = 'https://prog-info.o94.at/api.php'
export let endpointShows = 'shows'
export let endpointHosts = 'hosts'
export let endpointEpisodes = 'timeslots'
export let showSlug = undefined
export let episodeDaysFuture = 360
......@@ -27,7 +26,6 @@
let tmp_show // FIXME Workaround for current API limitations: It's not possible to fetch everything in one request (see below)
let show
let hosts
let episodes
let episodesNext
let labelEpisodes
......@@ -53,7 +51,7 @@
let urlSlug = url.searchParams.get('slug')
if (urlSlug) showSlug = urlSlug
let showUrl = `${api}/${endpointShows}/${showSlug}`
let showUrl = `${api}/${endpointShows}/${showSlug}?withHostDetails=true`
console.log('Show API Url:' + showUrl)
fetchApi(showUrl, processShowResponse)
})
......@@ -63,23 +61,10 @@
tmp_show = data
console.log('Shows API response:', data)
// #TODO Improve AURA API to do it in one request
hosts = []
if (tmp_show.hosts) {
for (const hostId of tmp_show.hosts) {
let hostsUrl = `${api}/${endpointHosts}/${hostId}`
fetchApi(hostsUrl, processHostsResponse)
}
}
fetchEpisodes()
}
/** Load hosts from the API */
function processHostsResponse(data) {
hosts.push(data)
console.log('Host API response:', data)
}
/** Load the initial Episodes from the API */
function fetchEpisodes() {
......@@ -162,7 +147,6 @@
{#if show}
<ShowCardBig
{show}
{hosts}
{episodes}
{urlEpisodeDetail}
{urlHostDetail}
......
......@@ -12,7 +12,6 @@
export let renderhtml = false // Attention: to avoid XSS attack vectors use with trusted API sources only
export let show = undefined
export let hosts = undefined
export let episodes = undefined
export let urlHostDetail = undefined
export let urlEpisodeDetail = undefined
......@@ -155,10 +154,10 @@
</ul>
</Content>
{#if hosts}
{#if show.hosts}
<Content class="host-section">
<div class="host-list-small card-container list contained">
{#each hosts as host}
{#each show.hosts as host}
<HostCardAvatar {host} {urlHostDetail} {renderhtml} displayOverlay={true} />
{/each}
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment