mirror of
https://github.com/kristoferssolo/traxor.git
synced 2025-10-21 20:10:35 +00:00
fix(move): path pre-population
This commit is contained in:
parent
eea85700e1
commit
8b82d09318
@ -170,7 +170,8 @@ impl<'a> App<'a> {
|
|||||||
|
|
||||||
pub fn prepare_move_action(&mut self) {
|
pub fn prepare_move_action(&mut self) {
|
||||||
if let Some(download_dir) = self.get_current_downlaod_dir() {
|
if let Some(download_dir) = self.get_current_downlaod_dir() {
|
||||||
self.set_input_from_path(&download_dir);
|
let path_buf = PathBuf::from(download_dir);
|
||||||
|
self.update_cursor(path_buf);
|
||||||
}
|
}
|
||||||
self.input_mode = true;
|
self.input_mode = true;
|
||||||
}
|
}
|
||||||
@ -227,27 +228,19 @@ impl<'a> App<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_current_downlaod_dir(&self) -> Option<String> {
|
fn get_current_downlaod_dir(&self) -> Option<PathBuf> {
|
||||||
match self.selected(true) {
|
match self.selected(true) {
|
||||||
Selected::Current(current_id) => self
|
Selected::Current(current_id) => self
|
||||||
.torrents
|
.torrents
|
||||||
.torrents
|
.torrents
|
||||||
.iter()
|
.iter()
|
||||||
.find(|&t| t.id == Some(current_id))
|
.find(|&t| t.id == Some(current_id))
|
||||||
.and_then(|t| t.download_dir.clone()),
|
.and_then(|t| t.download_dir.as_ref())
|
||||||
|
.map(PathBuf::from),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_input_from_path(&mut self, download_dir: &str) {
|
|
||||||
let mut path_buf = PathBuf::from(download_dir);
|
|
||||||
|
|
||||||
if path_buf.is_dir() && !download_dir.ends_with('/') {
|
|
||||||
path_buf.push("/");
|
|
||||||
}
|
|
||||||
self.update_cursor(path_buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_cursor(&mut self, path: PathBuf) {
|
fn update_cursor(&mut self, path: PathBuf) {
|
||||||
self.input = path.to_string_lossy().to_string();
|
self.input = path.to_string_lossy().to_string();
|
||||||
self.cursor_position = self.input.len();
|
self.cursor_position = self.input.len();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user