Babylonia-terminal/babylonia_terminal_launcher/native/hub/src/dependencies.rs
2024-08-25 17:39:17 +02:00

38 lines
1.2 KiB
Rust

use std::thread;
use babylonia_terminal_sdk::game_manager::GameManager;
use tokio_with_wasm::tokio;
use crate::{
messages::{
error::ReportError,
steps::dependencies::{
NotifyDependenciesSuccessfullyInstalled, StartDependenciesInstallation,
},
},
proton::get_proton,
};
pub async fn listen_dependecies_installation() {
let mut receiver = StartDependenciesInstallation::get_dart_signal_receiver().unwrap();
while let Some(_) = receiver.recv().await {
let proton = get_proton().await;
thread::spawn(move || {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap()
.block_on(async {
match GameManager::install_dependencies(&proton).await {
Err(e) => ReportError {
error_message: format!("Failed to install dependencies : {}", e),
}
.send_signal_to_dart(),
Ok(_) => NotifyDependenciesSuccessfullyInstalled {}.send_signal_to_dart(),
}
});
});
}
}