refactor: clear the quality-scan findings
`render_shortcuts` was 144 lines of "which shortcuts apply" wrapped around 40 lines of drawing; the decision moves into a `shortcuts` method beside the `rooms_shortcuts` helper that already worked this way. Three identically shaped comments over the popup guards collapse into one that carries the part worth knowing — an open popup owns the keyboard, so the order matters. The state tests trade bare `unwrap()` for `expect()` so a failure names the step.
This commit is contained in:
@@ -16,17 +16,13 @@ impl MainTui {
|
||||
return self.handle_chat_input(key);
|
||||
}
|
||||
|
||||
// Browse popup takes over navigation while open.
|
||||
// An open popup owns the keyboard, so these come before pane routing.
|
||||
if self.state.show_browse {
|
||||
return self.handle_browse_input(key);
|
||||
}
|
||||
|
||||
// Rooms popup takes over navigation while open.
|
||||
if self.state.show_rooms {
|
||||
return self.handle_rooms_input(key);
|
||||
}
|
||||
|
||||
// Settings popup takes over navigation while open.
|
||||
if self.state.settings.is_some() {
|
||||
return self.handle_settings_input(key);
|
||||
}
|
||||
@@ -149,7 +145,6 @@ impl MainTui {
|
||||
KeyCode::BackTab | KeyCode::Up | KeyCode::Char('k') => {
|
||||
self.state.cycle_chat_peer(false);
|
||||
}
|
||||
// Start a conversation with someone not in the list yet.
|
||||
KeyCode::Char('m') => {
|
||||
self.state.show_messages = false;
|
||||
self.state.command_bar_active = true;
|
||||
|
||||
@@ -298,8 +298,10 @@ impl MainTui {
|
||||
}
|
||||
}
|
||||
|
||||
fn render_shortcuts(&self, frame: &mut Frame, area: Rect) {
|
||||
let shortcuts = if self.state.settings.is_some() {
|
||||
/// Which shortcuts the bar offers, which is purely a question of what is
|
||||
/// open and where the focus sits. Sibling of [`Self::rooms_shortcuts`].
|
||||
fn shortcuts(&self) -> Vec<(&'static str, &'static str)> {
|
||||
if self.state.settings.is_some() {
|
||||
vec![
|
||||
("↑↓", "move"),
|
||||
("Enter/e", "edit download dir"),
|
||||
@@ -399,9 +401,11 @@ impl MainTui {
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
let shortcuts_line = format_shortcuts_styled(&shortcuts);
|
||||
fn render_shortcuts(&self, frame: &mut Frame, area: Rect) {
|
||||
let shortcuts_line = format_shortcuts_styled(&self.shortcuts());
|
||||
// Surface our own sharing status in the block title.
|
||||
let shared = self.client.shared_directories();
|
||||
let sharing = match shared.as_slice() {
|
||||
|
||||
Reference in New Issue
Block a user