mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-16 01:31:22 +10:00
feat(download ui): debug queue interface
This commit is contained in:
@ -19,21 +19,6 @@ pub fn download_game(
|
||||
.map_err(|_| "An error occurred while communicating with the download manager.".to_string())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_current_game_download_progress(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<f64, String> {
|
||||
match state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.download_manager
|
||||
.get_current_game_download_progress()
|
||||
{
|
||||
Some(progress) => Ok(progress),
|
||||
None => Err("Game does not exist".to_string()),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn cancel_game_download(state: tauri::State<'_, Mutex<AppState>>, game_id: String) {
|
||||
info!("Cancelling game download {}", game_id);
|
||||
@ -54,6 +39,19 @@ pub fn resume_game_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||
state.lock().unwrap().download_manager.resume_downloads()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn move_game_in_queue(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
old_index: usize,
|
||||
new_index: usize,
|
||||
) {
|
||||
state
|
||||
.lock()
|
||||
.unwrap()
|
||||
.download_manager
|
||||
.rearrange(old_index, new_index)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_current_write_speed(state: tauri::State<'_, Mutex<AppState>>) {}
|
||||
|
||||
|
||||
@ -132,19 +132,23 @@ impl DownloadManager {
|
||||
let current_index = get_index_from_id(&mut queue, id).unwrap();
|
||||
let to_move = queue.remove(current_index).unwrap();
|
||||
queue.insert(new_index, to_move);
|
||||
self.command_sender.send(DownloadManagerSignal::Update);
|
||||
}
|
||||
pub fn rearrange(&self, current_index: usize, new_index: usize) {
|
||||
let mut queue = self.edit();
|
||||
let to_move = queue.remove(current_index).unwrap();
|
||||
queue.insert(new_index, to_move);
|
||||
self.command_sender.send(DownloadManagerSignal::Update);
|
||||
}
|
||||
pub fn remove_from_queue(&self, index: usize) {
|
||||
self.edit().remove(index);
|
||||
self.command_sender.send(DownloadManagerSignal::Update);
|
||||
}
|
||||
pub fn remove_from_queue_string(&self, id: String) {
|
||||
let mut queue = self.edit();
|
||||
let current_index = get_index_from_id(&mut queue, id).unwrap();
|
||||
queue.remove(current_index);
|
||||
self.command_sender.send(DownloadManagerSignal::Update);
|
||||
}
|
||||
pub fn pause_downloads(&self) {
|
||||
self.command_sender
|
||||
|
||||
Reference in New Issue
Block a user