From 8602493331346ebc5d61a8daa507a952ff36b27f Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 25 Jan 2026 06:06:10 -0600 Subject: [PATCH] refactor(quality-badge): simplify to only detect MP3 format Simplified the lossy format detection since only MP3 is clearly lossy among supported library formats (flac, m4a, wav, aiff, ape, mp3). m4a can be either ALAC (lossless) or AAC (lossy) so it's not reliable. - Removed LOSSY_FORMATS array, now only checks for 'mp3' - Use /mp3.svg icon (text-only, more readable than mp3-cd.svg) - Simplified tier to just 'mp3' instead of 'mp3-cd' and 'lossy' --- src/lib/components/QualityBadge.svelte | 27 +++++++------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/lib/components/QualityBadge.svelte b/src/lib/components/QualityBadge.svelte index dd8b65729..2ca436f99 100644 --- a/src/lib/components/QualityBadge.svelte +++ b/src/lib/components/QualityBadge.svelte @@ -13,21 +13,13 @@ format }: Props = $props(); - // Define lossy formats - const LOSSY_FORMATS = ['mp3', 'aac', 'm4a', 'ogg', 'opus', 'wma']; - // Determine quality tier const tier = $derived.by(() => { const fmt = (format || quality || '').toLowerCase(); - // Check for lossy formats FIRST - they should never be "CD" quality - const isLossyFormat = LOSSY_FORMATS.some(f => fmt.includes(f)); - if (isLossyFormat) { - // MP3/lossy at CD-like sample rates gets special 'mp3-cd' tier - if (samplingRate && samplingRate >= 44.1 && samplingRate <= 48) { - return 'mp3-cd'; - } - return 'lossy'; + // Check for MP3 FIRST - it should never be "CD" quality + if (fmt.includes('mp3')) { + return 'mp3'; } // Check bitDepth and samplingRate for lossless formats @@ -78,12 +70,9 @@ const rate = samplingRate || 44.1; return `${depth}-bit / ${rate} kHz`; } - if (tier === 'mp3-cd') { + if (tier === 'mp3') { const rate = samplingRate || 44.1; - return `${rate} kHz (Lossy)`; - } - if (tier === 'lossy') { - return '320 kbps'; + return `${rate} kHz`; } return '16-bit / 44.1 kHz'; }); @@ -92,8 +81,7 @@ if (tier === 'max') return 'Hi-Res'; if (tier === 'hires') return 'Hi-Res'; if (tier === 'cd') return 'CD'; - if (tier === 'mp3-cd') return 'MP3'; - if (tier === 'lossy') return 'MP3'; + if (tier === 'mp3') return 'MP3'; return 'CD'; }); @@ -101,8 +89,7 @@ const iconPath = $derived.by(() => { if (tier === 'max' || tier === 'hires') return '/hi-res-gray.svg'; if (tier === 'cd') return '/cd.svg'; - if (tier === 'mp3-cd') return '/mp3-cd.svg'; - if (tier === 'lossy') return '/mp3.svg'; + if (tier === 'mp3') return '/mp3.svg'; return '/cd.svg'; });