Skip to content

Commit

Permalink
Add default book lists to default config. Closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
BrenekH committed Oct 11, 2024
1 parent 0ec2f71 commit a8619bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ pub static DEFAULT_CONFIG: &'static str = indoc! {r#"
"db_name": "",
"db_url": "",
"db_token": "",
"theme": "dark"
"theme": "dark",
"book_lists": ["In Progress", "Planned", "Aside", "Completed", "Dropped"]
}
"#};

Expand All @@ -43,6 +44,7 @@ pub struct Config {
pub db_url: String,
pub db_token: String,
pub theme: String,
pub book_lists: Vec<String>,
}

impl Config {
Expand Down Expand Up @@ -78,6 +80,13 @@ impl Config {
db_url: "".into(),
db_token: "".into(),
theme: "dark".into(),
book_lists: vec![
"In Progress".into(),
"Planned".into(),
"Aside".into(),
"Completed".into(),
"Dropped".into(),
],
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,15 @@ fn update_config(
db_url: String,
db_token: String,
theme: String,
book_lists: Vec<String>,
) -> Result<String> {
match config::write_config(Config {
username,
db_name,
db_url,
db_token,
theme,
book_lists,
}) {
Ok(_) => Ok(String::from("Wrote new config successfully!")),
Err(e) => Err(Error { msg: e }),
Expand Down

0 comments on commit a8619bc

Please sign in to comment.