mirror of
https://github.com/kristoferssolo/traxor.git
synced 2026-01-14 20:46:14 +00:00
fix: move torrent works with highlighted selection
This commit is contained in:
parent
3bbb1459f2
commit
baab8a1984
@ -107,6 +107,22 @@ impl Torrents {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Move torrents to a new location.
|
||||||
|
///
|
||||||
|
/// # Errors
|
||||||
|
///
|
||||||
|
/// Returns an error if the RPC call fails.
|
||||||
|
pub async fn move_torrents(&mut self, ids: Selected, location: &str) -> Result<()> {
|
||||||
|
let ids: Vec<Id> = ids.into();
|
||||||
|
if ids.is_empty() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
self.client
|
||||||
|
.torrent_set_location(ids, location.to_owned(), Some(true))
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Rename a torrent.
|
/// Rename a torrent.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
|
|||||||
@ -168,15 +168,19 @@ impl App {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Move selected or highlighted torrent(s) to a new location.
|
||||||
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// TODO: add error types
|
/// Returns an error if the RPC call fails.
|
||||||
pub async fn move_torrent(&mut self) -> Result<()> {
|
pub async fn move_torrent(&mut self) -> Result<()> {
|
||||||
|
let ids = self.selected(false);
|
||||||
self.torrents
|
self.torrents
|
||||||
.move_selection(&self.input_handler.text)
|
.move_torrents(ids, &self.input_handler.text)
|
||||||
.await?;
|
.await?;
|
||||||
self.input_handler.clear();
|
self.input_handler.clear();
|
||||||
self.input_mode = false;
|
self.input_mode = false;
|
||||||
|
self.close_help();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use crate::{app::constants::DEFAULT_RPC_URL, error::Result};
|
|||||||
use std::{collections::HashSet, fmt::Debug};
|
use std::{collections::HashSet, fmt::Debug};
|
||||||
use transmission_rpc::{
|
use transmission_rpc::{
|
||||||
TransClient,
|
TransClient,
|
||||||
types::{Id, Torrent, TorrentGetField},
|
types::{Torrent, TorrentGetField},
|
||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
@ -76,16 +76,6 @@ impl Torrents {
|
|||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Errors
|
|
||||||
///
|
|
||||||
/// TODO: add error types
|
|
||||||
pub async fn move_selection(&mut self, location: &str) -> Result<()> {
|
|
||||||
let ids: Vec<Id> = self.selected.iter().map(|id| Id::Id(*id)).collect();
|
|
||||||
self.client
|
|
||||||
.torrent_set_location(ids, location.to_string(), Some(true))
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for Torrents {
|
impl Debug for Torrents {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user