feat(downloads): Added function to take and set any game state

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-11-09 21:26:44 +11:00
parent f10d92d623
commit 6bc64822df
3 changed files with 27 additions and 69 deletions

View File

@ -116,33 +116,14 @@ pub async fn get_game_download_progress(
Ok(progress)
}
#[tauri::command]
pub async fn pause_game_download(
state: tauri::State<'_, Mutex<AppState>>,
game_id: String,
) -> Result<(), String> {
get_game_download(state, game_id).change_state(GameDownloadState::Paused);
Ok(())
}
#[tauri::command]
pub async fn resume_game_download(
state: tauri::State<'_, Mutex<AppState>>,
game_id: String,
) -> Result<(), String> {
get_game_download(state, game_id).change_state(GameDownloadState::Downloading);
Ok(())
}
#[tauri::command]
pub async fn set_download_state(
state: tauri::State<'_, Mutex<AppState>>,
game_id: String,
status: GameDownloadState
) -> Result<(), String> {
info!("Setting game state");
get_game_download(state, game_id).change_state(status);
Ok(())
}