From 9c3fd4c1a2e9e20ff517d04c8d3073da54017979 Mon Sep 17 00:00:00 2001 From: apt-get Date: Wed, 2 Sep 2026 18:23:22 +0200 Subject: [PATCH] formatting pass --- db/update_db.js | 5 +- src/lib/database.ts | 3 +- src/lib/streamContext.svelte.ts | 68 +++++++++---------- src/routes/streams/WelcomePage.svelte | 9 ++- .../streams/[stream_id]/+page.server.ts | 4 +- src/routes/streams/[stream_id]/Player.svelte | 12 ++-- .../streams/[stream_id]/StreamPage.svelte | 4 +- 7 files changed, 56 insertions(+), 49 deletions(-) diff --git a/db/update_db.js b/db/update_db.js index 823ba0b..2d5d77d 100644 --- a/db/update_db.js +++ b/db/update_db.js @@ -23,7 +23,10 @@ const lookup = { }; // Retrieve existing IDs from Stream -const existingIds = db.prepare('SELECT id FROM Stream').all().map(row => row.id); +const existingIds = db + .prepare('SELECT id FROM Stream') + .all() + .map((row) => row.id); // Create a set of existing IDs for efficient lookup const idSet = new Set(existingIds); diff --git a/src/lib/database.ts b/src/lib/database.ts index 8fdc1c1..6809b55 100644 --- a/src/lib/database.ts +++ b/src/lib/database.ts @@ -9,7 +9,8 @@ const db = new Database(dbName); export function getStreams(): StreamSummary[] { const indexData = db .prepare( - 'SELECT id, stream_date, filename, title, tags, length_seconds ' + 'FROM Stream ORDER BY id DESC' + 'SELECT id, stream_date, filename, title, tags, length_seconds ' + + 'FROM Stream ORDER BY id DESC' ) .all() as Record[]; return indexData.map((stream) => ({ diff --git a/src/lib/streamContext.svelte.ts b/src/lib/streamContext.svelte.ts index a0917f5..dda70b2 100644 --- a/src/lib/streamContext.svelte.ts +++ b/src/lib/streamContext.svelte.ts @@ -2,46 +2,46 @@ import { createContext } from 'svelte'; import type { Stream, StreamSummary } from './types.ts'; export class StreamContext { - streams: StreamSummary[]; - current = $state(null); - songIndex = $state(null); - #timestamps: number[] = []; + streams: StreamSummary[]; + current = $state(null); + songIndex = $state(null); + #timestamps: number[] = []; - constructor(streams: StreamSummary[]) { - this.streams = streams; - } + constructor(streams: StreamSummary[]) { + this.streams = streams; + } - setCurrent(stream: Stream) { - this.current = stream; - this.#timestamps = [-Infinity, ...stream.tracks.map((t) => t[0]), Infinity]; - this.songIndex = 0; - } + setCurrent(stream: Stream) { + this.current = stream; + this.#timestamps = [-Infinity, ...stream.tracks.map((t) => t[0]), Infinity]; + this.songIndex = 0; + } - clearCurrent() { - this.current = null; - this.songIndex = null; - } + clearCurrent() { + this.current = null; + this.songIndex = null; + } - getSongAtTime(time: number): number { - return this.#locationOf(time, this.#timestamps) - 1; - } + getSongAtTime(time: number): number { + return this.#locationOf(time, this.#timestamps) - 1; + } - updateCurrentSong(currentTime: number, songIndex: number) { - const ts = this.#timestamps; - const recurse = (idx: number): number => { - if (currentTime >= ts[idx + 2]) return recurse(idx + 1); - if (currentTime < ts[idx + 1]) return recurse(idx - 1); - return idx; - }; - this.songIndex = recurse(songIndex); - } + updateCurrentSong(currentTime: number, songIndex: number) { + const ts = this.#timestamps; + const recurse = (idx: number): number => { + if (currentTime >= ts[idx + 2]) return recurse(idx + 1); + if (currentTime < ts[idx + 1]) return recurse(idx - 1); + return idx; + }; + this.songIndex = recurse(songIndex); + } - #locationOf(element: number, array: number[], start = 0, end = array.length): number { - const pivot = Math.floor(start + (end - start) / 2); - if (end - start <= 1 || array[pivot] === element) return pivot; - if (array[pivot] < element) return this.#locationOf(element, array, pivot, end); - return this.#locationOf(element, array, start, pivot); - } + #locationOf(element: number, array: number[], start = 0, end = array.length): number { + const pivot = Math.floor(start + (end - start) / 2); + if (end - start <= 1 || array[pivot] === element) return pivot; + if (array[pivot] < element) return this.#locationOf(element, array, pivot, end); + return this.#locationOf(element, array, start, pivot); + } } export const [getStreamContext, setStreamContext] = createContext(); diff --git a/src/routes/streams/WelcomePage.svelte b/src/routes/streams/WelcomePage.svelte index 56683ce..b3cf028 100644 --- a/src/routes/streams/WelcomePage.svelte +++ b/src/routes/streams/WelcomePage.svelte @@ -13,10 +13,13 @@

Hello, there, welcome to V1.6.

- 2026-03-16 update: you can now cache streams offline for playback in low-connectivity environments (and to prevent buffering)!
- Simply click on the download icon in the stream list (and click again to remove them from cache). You can also filter by cached streams at the top. This all goes into your browser storage, and a stream is generally 100~250MB depending on its length. + 2026-03-16 update: you can now cache streams offline for playback in low-connectivity + environments (and to prevent buffering)!
+ Simply click on the download icon in the stream list (and click again to remove them from cache). + You can also filter by cached streams at the top. This all goes into your browser storage, and + a stream is generally 100~250MB depending on its length.

-
+

Still in construction. The design is responsive now, so phones should work well enough! Needs touch events though. diff --git a/src/routes/streams/[stream_id]/+page.server.ts b/src/routes/streams/[stream_id]/+page.server.ts index 5daa405..5a2a4de 100644 --- a/src/routes/streams/[stream_id]/+page.server.ts +++ b/src/routes/streams/[stream_id]/+page.server.ts @@ -46,9 +46,7 @@ export function load({ params }) { error(404); } - result.descriptionHtml = Bun.markdown.html( - result.description || 'No description available.' - ); + result.descriptionHtml = Bun.markdown.html(result.description || 'No description available.'); if (dev) { // pass raw JSON for metadata editor diff --git a/src/routes/streams/[stream_id]/Player.svelte b/src/routes/streams/[stream_id]/Player.svelte index 3a63fe6..a9cf908 100644 --- a/src/routes/streams/[stream_id]/Player.svelte +++ b/src/routes/streams/[stream_id]/Player.svelte @@ -230,7 +230,6 @@ } }); }); - { seeking = true; updateSeekVisual(e); }} + onmousedown={(e) => { + seeking = true; + updateSeekVisual(e); + }} onmouseenter={() => (showTooltip = true)} onmouseleave={() => (showTooltip = false)} style="--primary-color:{barPrimaryColor}; --secondary-color:{barSecondaryColor}" class="song-progress" > -

{formatSeconds(currentTime, duration >= 3600)}/{formatSeconds(duration)}
+
+ {formatSeconds(currentTime, duration >= 3600)}/{formatSeconds(duration)} +