better stopping, better file pre-selecting
This commit is contained in:
parent
7eccbaeb9e
commit
d84a046ec9
5 changed files with 14 additions and 11 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1324,7 +1324,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "jocalsend"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"axum-server",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "jocalsend"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -134,7 +134,7 @@ impl App {
|
|||
| CurrentScreen::Sending(SendingScreen::Files)
|
||||
| CurrentScreen::Sending(SendingScreen::Peers) => match code {
|
||||
KeyCode::Esc => self.pop(),
|
||||
KeyCode::Char('q') => self.exit(),
|
||||
KeyCode::Char('q') => self.exit().await,
|
||||
KeyCode::Char('s') => self.send(),
|
||||
KeyCode::Char('r') => self.recv(),
|
||||
KeyCode::Char('l') => self.logs(),
|
||||
|
@ -206,8 +206,9 @@ impl App {
|
|||
frame.render_widget(self, frame.area());
|
||||
}
|
||||
|
||||
pub fn exit(&mut self) {
|
||||
pub async fn exit(&mut self) {
|
||||
self.screen.push(CurrentScreen::Stopping);
|
||||
self.service.stop().await;
|
||||
}
|
||||
|
||||
pub fn send(&mut self) {
|
||||
|
|
|
@ -136,7 +136,7 @@ impl Widget for &mut App {
|
|||
// one element in `self.screen`; see the `self.pop()` method
|
||||
let current_screen = self.screen();
|
||||
match current_screen {
|
||||
CurrentScreen::Main => {
|
||||
CurrentScreen::Main | CurrentScreen::Stopping => {
|
||||
let rx_reqs: Vec<_> = self.receive_requests.values().collect();
|
||||
outer_frame(¤t_screen, &MAIN_MENU, area, buf);
|
||||
logger(header_right.inner(header_margin), buf);
|
||||
|
@ -213,9 +213,6 @@ impl Widget for &mut App {
|
|||
// function
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
outer_frame(¤t_screen, &MAIN_MENU, area, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -64,7 +64,6 @@ async fn start_and_run(terminal: &mut DefaultTerminal, config: Config) -> Result
|
|||
app.handle_events().await?;
|
||||
|
||||
if app.screen() == CurrentScreen::Stopping {
|
||||
app.service.stop().await;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -128,11 +127,17 @@ fn set_file_selection(path: &Path, explorer: &mut FileExplorer) {
|
|||
let parent = path.parent().map(|f| f.to_path_buf()).unwrap_or("/".into());
|
||||
let _ = explorer.set_cwd(parent);
|
||||
};
|
||||
let files = explorer.files().clone();
|
||||
|
||||
let files = explorer.files();
|
||||
let mut idx = None;
|
||||
for (i, f) in files.iter().enumerate() {
|
||||
if f.name() == path.file_name().unwrap().to_string_lossy() {
|
||||
explorer.set_selected_idx(i);
|
||||
idx = Some(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(idx) = idx {
|
||||
explorer.set_selected_idx(idx);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue