Skip to content

Commit

Permalink
fix: studio now playing glitch on station list on station index > 30
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroaisen committed Nov 14, 2023
1 parent 9a380b9 commit 1066ab0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export const load = (async ({ fetch, url, parent, depends, params }) => {
const to_fetch_stations = stations
.items
.filter(item => item.account_id === account._id)
.sort((a, b) => {
return (sessions_by_station[b._id] || 0) - (sessions_by_station[a._id] || 0)
})
.sort((a, b) => (sessions_by_station[b._id] || 0) - (sessions_by_station[a._id] || 0))
.slice(0, 30)

// fetch the now playing of first 30 satations (approx the maximum visible ones on non-scrolled screen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
| import('$api/stations/[station]/now-playing/GET/Output').Output
| undefined = undefined;
$: on_air = now_playing && !(now_playing.kind === 'none' && !now_playing.start_on_connect);
let current_now_playing: import('$api/stations/[station]/now-playing/GET/Output').Output | null = null;
$: merged_now_playing = current_now_playing ?? now_playing;
$: on_air = merged_now_playing && !(merged_now_playing.kind === 'none' && !merged_now_playing.start_on_connect);
let store: ReturnType<typeof get_now_playing_store> | null;
let unsub: (() => void) | null = null;
onMount(() => {
store = get_now_playing_store(station._id, now_playing || null);
store = get_now_playing_store(station._id, current_now_playing || null);
unsub = store.subscribe((v) => {
now_playing = v?.info || undefined;
current_now_playing = v?.info || null;
});
return () => {
Expand All @@ -31,9 +35,9 @@
const enter = () => {
if (store != null) return;
store = get_now_playing_store(station._id, now_playing || null);
store = get_now_playing_store(station._id, current_now_playing || null);
unsub = store.subscribe((v) => {
now_playing = v?.info || undefined;
current_now_playing = v?.info || null;
});
};
Expand Down Expand Up @@ -122,7 +126,7 @@
<div class="name">{station.name}</div>

<div class="now-playing-sessions">
{#if now_playing}
{#if merged_now_playing}
<div class="now-playing-state">
{#if on_air}
{$locale.pages['account/dashboard'].station_item.on_air}
Expand All @@ -142,10 +146,10 @@
</div>


{#if now_playing.kind === 'none'}
{#if now_playing.start_on_connect}
{#if merged_now_playing.kind === 'none'}
{#if merged_now_playing.start_on_connect}
<div class="now-playing-sub">
{#if now_playing.external_relay_url != null}
{#if merged_now_playing.external_relay_url != null}
{$locale.misc.Relay}
{:else}
{$locale.pages['account/dashboard'].station_item.playlist}
Expand All @@ -154,11 +158,11 @@
{/if}
{:else}
<div class="now-playing-sub">
{#if now_playing.kind === 'live'}
{#if merged_now_playing.kind === 'live'}
{$locale.pages['account/dashboard'].station_item.live}
{:else if now_playing.kind === 'playlist'}
{:else if merged_now_playing.kind === 'playlist'}
{$locale.pages['account/dashboard'].station_item.playlist}
{:else if now_playing.kind === 'external-relay'}
{:else if merged_now_playing.kind === 'external-relay'}
{$locale.misc.Relay}
{/if}
</div>
Expand Down
4 changes: 2 additions & 2 deletions rs/packages/stream/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ impl StreamHandler {
let mut rx_had_data = false;

if loop_i != 0 {
info!("LOOP {loop_i} conn {conn_id} {ip} - station: {station_id} ({station_name})");
info!("LOOP {loop_i} conn {conn_id} {ip} - {station_id} ({station_name})");
}

loop_i += 1;
Expand Down Expand Up @@ -676,7 +676,7 @@ impl Drop for StreamConnectionDropper {
let domain = domain.as_deref().unwrap_or("???");
let s = duration_ms as f64 / 1_000.0;
let end_reason = end_reason.lock();
info!("END conn {id} {ip} - station: {station_id} ({station_name}) in {domain} | reason={end_reason} - {s} s");
info!("END conn {id} {ip} - {station_id} ({station_name}) in {domain} | reason={end_reason} - {s} s");
}

tokio::spawn(async move {
Expand Down

0 comments on commit 1066ab0

Please sign in to comment.