diff --git a/rm-main/src/ui/tabs/torrents/bottom_stats.rs b/rm-main/src/ui/tabs/torrents/bottom_stats.rs index 5392db8..230cbf0 100644 --- a/rm-main/src/ui/tabs/torrents/bottom_stats.rs +++ b/rm-main/src/ui/tabs/torrents/bottom_stats.rs @@ -36,8 +36,10 @@ impl BottomStats { } pub fn update_selected_indicator(&mut self, table_manager: &TableManager) { - self.torrent_count = table_manager.torrents_displaying_no; - self.torrent_currently_selected = u16::try_from(table_manager.table.get_len()).unwrap() + 1; + self.torrent_count = u16::try_from(table_manager.table.items.len()).unwrap(); + if let Some(currently_selected) = table_manager.table.state.borrow().selected() { + self.torrent_currently_selected = u16::try_from(currently_selected + 1).unwrap(); + } } } impl Component for BottomStats { diff --git a/rm-main/src/ui/tabs/torrents/mod.rs b/rm-main/src/ui/tabs/torrents/mod.rs index 934aa20..9de850f 100644 --- a/rm-main/src/ui/tabs/torrents/mod.rs +++ b/rm-main/src/ui/tabs/torrents/mod.rs @@ -137,6 +137,8 @@ impl Component for TorrentsTab { } UpdateAction::UpdateTorrents(torrents) => { self.table_manager.set_new_rows(torrents); + self.bottom_stats + .update_selected_indicator(&self.table_manager); } _ => (), } @@ -188,33 +190,45 @@ impl TorrentsTab { fn previous_torrent(&mut self) { self.table_manager.table.previous(); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); } fn next_torrent(&mut self) { self.table_manager.table.next(); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); } fn scroll_page_down(&mut self) { let scroll_by = self.table_manager.torrents_displaying_no; self.table_manager.table.scroll_down_by(scroll_by as usize); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); } fn scroll_page_up(&mut self) { let scroll_by = self.table_manager.torrents_displaying_no; self.table_manager.table.scroll_up_by(scroll_by as usize); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); } fn scroll_to_home(&mut self) { self.table_manager.table.scroll_to_home(); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); } fn scroll_to_end(&mut self) { self.table_manager.table.scroll_to_end(); + self.bottom_stats + .update_selected_indicator(&self.table_manager); self.ctx.send_action(Action::Render); }