From db71c4a3319141f6b1c14748fabc0d1ca50f121f Mon Sep 17 00:00:00 2001 From: XShine555 Date: Mon, 20 Jul 2026 07:28:12 +0200 Subject: [PATCH] refactor(web): share track target helpers between home and explore Both pages reimplemented the same accessors over the target union and a byte-identical queue-item mapper. Moves the domain type (renamed ContextMenuTarget -> TrackTarget, since tiles and the queue use it too) and its helpers to $lib/tracks.ts; TrackContextMenu keeps only its menu geometry. Home drops from 341 to ~230 lines. Unifies two divergences the duplication was hiding: home compared the active tile against track.id while the queue is keyed by queueIdForTrack, so YouTube-sourced tracks never highlighted; and it hardcoded explicit to false for local tracks, hiding the badge. Also cancels in-flight youtube filler results when the effect re-runs, so a slow response cannot overwrite newer ones. --- .../lib/components/TrackContextMenu.svelte | 14 +- frontend/src/lib/tracks.ts | 79 +++++++++ .../src/routes/(app)/explore/+page.svelte | 109 ++++-------- frontend/src/routes/+page.svelte | 164 +++++------------- 4 files changed, 167 insertions(+), 199 deletions(-) create mode 100644 frontend/src/lib/tracks.ts diff --git a/frontend/src/lib/components/TrackContextMenu.svelte b/frontend/src/lib/components/TrackContextMenu.svelte index 7d66c2b..408a5e8 100644 --- a/frontend/src/lib/components/TrackContextMenu.svelte +++ b/frontend/src/lib/components/TrackContextMenu.svelte @@ -1,20 +1,12 @@