mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-23 00:12:53 +10:00
f1bba5cc74
* chore: Progress on amend_settings command Signed-off-by: quexeky <git@quexeky.dev> * chore(errors): Progress on better error handling with segragation of files * chore: Progress on amend_settings command Signed-off-by: quexeky <git@quexeky.dev> * chore(commands): Separated commands under each subdirectory into respective commands.rs files Signed-off-by: quexeky <git@quexeky.dev> * chore(errors): Almost all errors and commands have been segregated * chore(errors): Added drop server error Signed-off-by: quexeky <git@quexeky.dev> * feat(core): Update to using nightly compiler Signed-off-by: quexeky <git@quexeky.dev> * chore(errors): More progress on error handling Signed-off-by: quexeky <git@quexeky.dev> * chore(errors): Implementing Try and FromResidual for UserValue Signed-off-by: quexeky <git@quexeky.dev> * refactor(errors): Segregated errors and commands from code, and made commands return UserValue struct Signed-off-by: quexeky <git@quexeky.dev> * fix(errors): Added missing files * chore(errors): Convert match statement to map_err * feat(settings): Implemented settings editing from UI * feat(errors): Clarified return values from retry_connect command * chore(errors): Moved autostart commands to autostart.rs * chore(process manager): Converted launch_process function for games to use game_id --------- Signed-off-by: quexeky <git@quexeky.dev>
32 lines
863 B
Rust
32 lines
863 B
Rust
use std::sync::{mpsc::SendError, Arc, Mutex};
|
|
|
|
use crate::{
|
|
download_manager::{download_manager::DownloadManagerSignal, downloadable::Downloadable},
|
|
error::user_error::UserValue,
|
|
AppState,
|
|
};
|
|
|
|
use super::download_agent::GameDownloadAgent;
|
|
|
|
#[tauri::command]
|
|
pub fn download_game(
|
|
game_id: String,
|
|
game_version: String,
|
|
install_dir: usize,
|
|
state: tauri::State<'_, Mutex<AppState>>,
|
|
) -> UserValue<(), SendError<DownloadManagerSignal>> {
|
|
let sender = state.lock().unwrap().download_manager.get_sender();
|
|
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
|
game_id,
|
|
game_version,
|
|
install_dir,
|
|
sender,
|
|
)) as Box<dyn Downloadable + Send + Sync>);
|
|
state
|
|
.lock()
|
|
.unwrap()
|
|
.download_manager
|
|
.queue_download(game_download_agent)
|
|
.into()
|
|
}
|