Skip to content

Commit

Permalink
fix: being stuck in filtering bar, default keymap (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski authored Sep 8, 2024
1 parent 35c143b commit ec1680e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions rm-config/defaults/keymap.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ keybindings = [
{ on = "f", action = "ShowFiles" },
{ on = "s", action = "ShowStats" },

{ on = "d", action = "DeleteWithoutFiles" },
{ on = "D", action = "DeleteWithFiles" },
{ on = "d", action = "Delete" },
]

[search_tab]
Expand Down
2 changes: 1 addition & 1 deletion rm-main/src/tui/components/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl<T: Clone> GenericTable<T> {
let new_selection = state.selected().unwrap_or_default() + amount;

if new_selection > self.get_len() {
state.select(Some(self.get_len() - 1));
state.select(Some(self.get_len().saturating_sub(1)));
} else {
state.select(Some(new_selection));
};
Expand Down
2 changes: 1 addition & 1 deletion rm-main/src/tui/tabs/torrents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Component for TorrentsTab {
self.popup_manager.handle_update_action(action)
}
UpdateAction::CancelTorrentTask => {
if !self.task_manager.is_finished_status_task() {
if self.task_manager.is_status_task_in_progress() {
return;
}

Expand Down
5 changes: 5 additions & 0 deletions rm-main/src/tui/tabs/torrents/table_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ impl TableManager {
self.widths = self.header_widths(&self.table.items);
self.update_rows_number();
self.sort();

let mut state = self.table.state.borrow_mut();
if state.selected().is_none() && !self.table.items.is_empty() {
state.select(Some(0));
}
}

pub fn set_filter(&mut self, filter: String) {
Expand Down
4 changes: 2 additions & 2 deletions rm-main/src/tui/tabs/torrents/task_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ impl TaskManager {
self.ctx.send_update_action(UpdateAction::CancelTorrentTask);
}

pub fn is_finished_status_task(&self) -> bool {
pub fn is_status_task_in_progress(&self) -> bool {
if let CurrentTask::Status(task) = &self.current_task {
!matches!(task.task_status, CurrentTaskState::Loading(_))
matches!(task.task_status, CurrentTaskState::Loading(_))
} else {
false
}
Expand Down

0 comments on commit ec1680e

Please sign in to comment.