Skip to content

Commit

Permalink
fix: do not render image with no extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Sep 7, 2024
1 parent 70c4e6e commit 28a13dd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
14 changes: 8 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lala_bar/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ iced = { version = "0.12", features = [
] }
#iced_native = "0.12"
iced_runtime = "0.12"
iced_layershell = "0.5.1"
iced_layershell = "0.6.0"
tokio = { version = "1.40", features = ["full"] }
iced_futures = "0.12.0"
env_logger = "0.11.5"
Expand Down
33 changes: 25 additions & 8 deletions lala_bar/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,16 +424,23 @@ impl LalaMusicBar {
let mut view_elements: Vec<Element<Message>> = vec![];

if let Some(data) = &self.service_data {
if let Some(art_url) = url::Url::parse(&data.metadata.mpris_arturl)
let art_url_str = &data.metadata.mpris_arturl;
if let Some(art_url) = url::Url::parse(art_url_str)
.ok()
.and_then(|url| url.to_file_path().ok())
{
view_elements.push(
container(image(image::Handle::from_path(art_url)).width(Length::Fill))
.padding(10)
.width(Length::Fill)
.into(),
);
// HACK: not render soem thing like "/tmp/.org.chromium.Chromium.hYbnBf"

Check warning on line 432 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"soem" should be "some".
if art_url_str.ends_with("png")
|| art_url_str.ends_with("jpeg")
|| art_url_str.ends_with("jpg")
{
view_elements.push(
container(image(image::Handle::from_path(art_url)).width(Length::Fill))
.padding(10)
.width(Length::Fill)
.into(),
);
}
view_elements.push(Space::with_height(10.).into());
view_elements.push(
container(
Expand Down Expand Up @@ -542,7 +549,17 @@ impl LalaMusicBar {
let art_url = self
.service_data
.as_ref()
.and_then(|data| url::Url::parse(&data.metadata.mpris_arturl).ok())
.and_then(|data| {
let art_url_str = &data.metadata.mpris_arturl;
// HACK: not render soem thing like "/tmp/.org.chromium.Chromium.hYbnBf"

Check warning on line 554 in lala_bar/src/main.rs

View workflow job for this annotation

GitHub Actions / build

"soem" should be "some".
if !art_url_str.ends_with("png")
&& !art_url_str.ends_with("jpeg")
&& !art_url_str.ends_with("jpg")
{
return None;
}
url::Url::parse(art_url_str).ok()
})
.and_then(|url| url.to_file_path().ok());
let title = container(
text(title)
Expand Down

0 comments on commit 28a13dd

Please sign in to comment.