Skip to content

Commit

Permalink
removed duplicate code in save_config on main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aquilesorei authored and jackpot51 committed Jan 11, 2024
1 parent cb1b81c commit c7329b4
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

let (config_handler, config) = match cosmic_config::Config::new(App::APP_ID, CONFIG_VERSION) {
Ok(config_handler) => {
let config = match Config::get_entry(&config_handler) {
Ok(ok) => ok,
Err((errs, config)) => {
log::info!("errors loading config: {:?}", errs);
config
}
};
let config = Config::get_entry(&config_handler).unwrap_or_else(|(errs, config)| {
log::info!("errors loading config: {:?}", errs);
config
});
(Some(config_handler), config)
}
Err(err) => {
Expand Down Expand Up @@ -445,11 +442,6 @@ impl App {
}

fn save_config(&mut self) -> Command<Message> {
if let Some(ref config_handler) = self.config_handler {
if let Err(err) = self.config.write_entry(config_handler) {
log::error!("failed to save config: {}", err);
}
}

if let Some(ref config_handler) = self.config_handler {
if let Err(err) = self.config.write_entry(config_handler) {
Expand Down

0 comments on commit c7329b4

Please sign in to comment.