Skip to content

Commit

Permalink
Implement default for button
Browse files Browse the repository at this point in the history
  • Loading branch information
Radiicall committed Mar 13, 2024
1 parent 1163cfe commit 699d602
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
18 changes: 1 addition & 17 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions jellyfin-rpc-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ retry = "2.0"

[dependencies.jellyfin-rpc]
features = ["imgur", "cli"]
version = "1.0.2"
#path = "../jellyfin-rpc"
#version = "1.0.2"
path = "../jellyfin-rpc"

[dependencies.clap]
features = ["derive"]
Expand Down
6 changes: 1 addition & 5 deletions jellyfin-rpc-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Set the activity
let mut rpcbuttons: Vec<activity::Button> = vec![];
let mut x = 0;
let default_button = config::Button {
name: String::from("dynamic"),
url: String::from("dynamic"),
};
let buttons = config
.clone()
.discord
.and_then(|discord| discord.buttons)
.unwrap_or(vec![default_button.clone(), default_button]);
.unwrap_or(vec![config::Button::default(), config::Button::default()]);

// For loop to determine if external services are to be used or if there are custom buttons instead
for button in buttons.iter() {
Expand Down
9 changes: 9 additions & 0 deletions jellyfin-rpc/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ pub struct Button {
pub url: String,
}

impl Default for Button {
fn default() -> Self {
Self {
name: String::from("dynamic"),
url: String::from("dynamic"),
}
}
}

/// Imgur configuration
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Imgur {
Expand Down

0 comments on commit 699d602

Please sign in to comment.