From b3f191744198e6814e64f2c00634f2f09a0b8e36 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 21 Feb 2026 15:48:05 +0100 Subject: [PATCH] Optimize album art URL handling and simplify image display logic This commit refactors the album art URL normalization logic in Rust to use match expressions for cleaner and more concise code. It also simplifies the image display logic in Vue by removing the redundant cacheBustedUrl check, ensuring the image is displayed based solely on load and error states. --- .../components/pmocontrol/CurrentTrack.vue | 16 +++---- pmoparadise/src/source.rs | 43 ++++++++++--------- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/pmoapp/webapp/src/components/pmocontrol/CurrentTrack.vue b/pmoapp/webapp/src/components/pmocontrol/CurrentTrack.vue index fd0248bb..b74dd280 100644 --- a/pmoapp/webapp/src/components/pmocontrol/CurrentTrack.vue +++ b/pmoapp/webapp/src/components/pmocontrol/CurrentTrack.vue @@ -350,20 +350,14 @@ const swipeOpacity = computed(() => { @click="openCoverOverlay" > Some(format!("{}{}", self.base_url, art)), + Some(_) => Some(self.default_cover_url()), // URL externe brute → fallback local + None => Some(self.default_cover_url()), + }; } Ok(items) @@ -590,13 +588,11 @@ impl RadioParadiseSource { item.genre = Some("Radio Paradise".to_string()); } - if let Some(art) = item.album_art.as_mut() { - if art.starts_with('/') { - *art = format!("{}{}", self.base_url, art); - } - } else { - item.album_art = Some(self.default_cover_url()); - } + item.album_art = match item.album_art.take() { + Some(art) if art.starts_with('/') => Some(format!("{}{}", self.base_url, art)), + Some(_) => Some(self.default_cover_url()), + None => Some(self.default_cover_url()), + }; } Ok(items) @@ -921,6 +917,13 @@ impl MusicSource for RadioParadiseSource { if item.genre.is_none() { item.genre = Some("Radio Paradise".to_string()); } + item.album_art = match item.album_art.take() { + Some(art) if art.starts_with('/') => { + Some(format!("{}{}", self.base_url, art)) + } + Some(_) => Some(self.default_cover_url()), + None => Some(self.default_cover_url()), + }; adjusted.push(item); } @@ -987,13 +990,13 @@ impl MusicSource for RadioParadiseSource { item.genre = Some("Radio Paradise".to_string()); } - if let Some(art) = item.album_art.as_mut() { - if art.starts_with('/') { - *art = format!("{}{}", self.base_url, art); + item.album_art = match item.album_art.take() { + Some(art) if art.starts_with('/') => { + Some(format!("{}{}", self.base_url, art)) } - } else { - item.album_art = Some(self.default_cover_url()); - } + Some(_) => Some(self.default_cover_url()), + None => Some(self.default_cover_url()), + }; let expected_id = format!("radio-paradise:channel:{}:liveplaylist:track:{}", slug, pk);