Skip to content

Commit

Permalink
Fixes issues with custom buttons and forbids dynamic buttons with loc…
Browse files Browse the repository at this point in the history
…alhost urls
  • Loading branch information
Radiicall committed Aug 26, 2024
1 parent db3ea49 commit 34aa12b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions jellyfin-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ impl Client {
}

if button.is_dynamic() {
if ext_urls.len() - 1 == i {
if ext_urls.len() - 1 >= i {
if ext_urls[i].url.starts_with("http://localhost") || ext_urls[i].url.starts_with("https://localhost") {
continue;
}
activity_buttons.push(Button::new(
ext_urls[i].name.clone(),
ext_urls[i].url.clone(),
Expand All @@ -264,24 +267,28 @@ impl Client {
}
}
return Some(activity_buttons);
} else if let Some(ext_urls) = &session.now_playing_item.external_urls {
for ext_url in ext_urls {
} else if let Some(buttons) = self.buttons.as_ref() {
for button in buttons {
if activity_buttons.len() == 2 {
break;
}

activity_buttons.push(Button::new(ext_url.name.clone(), ext_url.url.clone()))
if !button.is_dynamic() {
activity_buttons.push(button.clone())
}
}
return Some(activity_buttons);
} else if let Some(buttons) = self.buttons.as_ref() {
for button in buttons {
} else if let Some(ext_urls) = &session.now_playing_item.external_urls {
for ext_url in ext_urls {
if ext_url.url.starts_with("http://localhost") || ext_url.url.starts_with("https://localhost") {
continue;
}

if activity_buttons.len() == 2 {
break;
}

if !button.is_dynamic() {
activity_buttons.push(button.clone())
}
activity_buttons.push(Button::new(ext_url.name.clone(), ext_url.url.clone()))
}
return Some(activity_buttons);
}
Expand Down

0 comments on commit 34aa12b

Please sign in to comment.