mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Fix UI version hanging on image download (#40)
Done by using task::spawn_blocking and blockon
This commit is contained in:
+1
-3
@@ -8,7 +8,7 @@ use config::{Config, ConfigError, Environment, File};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::env;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Settings {
|
||||
pub debug: bool,
|
||||
pub epic_games: EpicGamesLauncherSettings,
|
||||
@@ -50,8 +50,6 @@ impl Settings {
|
||||
|
||||
sanitize_auth_key(&mut result);
|
||||
|
||||
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[derive(Debug, Serialize, Deserialize,Clone)]
|
||||
pub struct SteamGridDbSettings {
|
||||
pub enabled: bool,
|
||||
pub auth_key: Option<String>,
|
||||
|
||||
+14
-5
@@ -30,10 +30,20 @@ pub async fn run_ui() -> Result<(), Box<dyn Error>> {
|
||||
let synch_ui = ui.clone();
|
||||
let sync_settings = settings.clone();
|
||||
synch_bytton.set_callback(move |cb| {
|
||||
update_settings_with_ui_values(&mut sync_settings.borrow_mut(), &synch_ui);
|
||||
match block_on(run_sync(&sync_settings.borrow())) {
|
||||
let mut settings_clone = sync_settings.borrow().clone();
|
||||
update_settings_with_ui_values(&mut settings_clone, &synch_ui);
|
||||
use tokio::task;
|
||||
let task = task::spawn_blocking(move || {
|
||||
let setting_ref = settings_clone.clone();
|
||||
let synchro_task = run_sync(&setting_ref);
|
||||
match block_on(synchro_task) {
|
||||
Ok(_) => println!("Finished sync"),
|
||||
Err(e) => println!("{}", e),
|
||||
}
|
||||
});
|
||||
match block_on(task){
|
||||
Ok(_) => cb.set_label("Synched"),
|
||||
Err(e) => println!("{}", e),
|
||||
Err(_) => cb.set_label("Error Synching"),
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -78,7 +88,6 @@ fn update_settings_with_ui_values(settings: &mut Settings, ui: &UserInterface) {
|
||||
settings.gog.location = empty_or_whitespace(ui.gog_folder_input.value());
|
||||
settings.gog.wine_c_drive = empty_or_whitespace(ui.gog_winedrive_input.value());
|
||||
|
||||
|
||||
// Uplay
|
||||
settings.uplay.enabled = ui.enable_uplay_checkbox.value();
|
||||
}
|
||||
@@ -184,6 +193,6 @@ fn update_ui_with_settings(ui: &mut UserInterface, settings: &Settings) {
|
||||
{
|
||||
ui.gog_winedrive_input.hide();
|
||||
}
|
||||
|
||||
|
||||
ui.enable_uplay_checkbox.set_value(settings.uplay.enabled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user