Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,7 @@ impl cosmic::Application for AppModel {
nav,
key_binds: HashMap::new(),
// Optional configuration file for an application.
config: cosmic_config::Config::new(Self::APP_ID, Config::VERSION)
.map(|context| match Config::get_entry(&context) {
Ok(config) => config,
Err((errors, config)) => {
for why in errors {
tracing::error!(%why, "error loading app config");
}

config
}
})
.unwrap_or_default(),
config: Config::default(),
status: fl!("status-connecting"),
device_path: None,
device_proxy: None,
Expand Down Expand Up @@ -170,7 +159,34 @@ impl cosmic::Application for AppModel {
cosmic::Action::App,
);

(app, command.chain(connect_task))
let config_task = Task::perform(
async move {
let config = tokio::task::spawn_blocking(move || {
cosmic_config::Config::new(Self::APP_ID, Config::VERSION)
.map(|context| match Config::get_entry(&context) {
Ok(config) => config,
Err((errors, config)) => {
for why in errors {
tracing::error!(%why, "error loading app config");
}

config
}
})
.unwrap_or_default()
})
.await
.unwrap_or_else(|e| {
tracing::error!("Config task join error: {}", e);
Config::default()
});

Message::UpdateConfig(config)
},
cosmic::Action::App,
);

(app, Task::batch(vec![command, connect_task, config_task]))
}

/// Elements to pack at the start of the header bar.
Expand Down
Loading