Skip to content

Commit

Permalink
be smarter about triggering render
Browse files Browse the repository at this point in the history
  • Loading branch information
micielski committed Jul 16, 2024
1 parent 94c1327 commit 54ed6f3
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 12 deletions.
5 changes: 2 additions & 3 deletions rm-main/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,14 @@ impl App {
match action {
UpdateAction::SwitchToInputMode => {
self.mode = Mode::Input;
self.ctx.send_action(Action::Render);
}
UpdateAction::SwitchToNormalMode => {
self.mode = Mode::Normal;
self.ctx.send_action(Action::Render);
}

_ => self.main_window.handle_update_action(action),
}
};
self.ctx.send_action(Action::Render);
}

fn tick(&mut self) {
Expand Down
1 change: 0 additions & 1 deletion rm-main/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl Component for MainWindow {
UpdateAction::Error(err) => {
let error_popup = ErrorPopup::new(err.title, err.description, err.source);
self.global_popup_manager.error_popup = Some(error_popup);
self.ctx.send_action(Action::Render);
}
action if self.tabs.current_tab == CurrentTab::Torrents => {
self.torrents_tab.handle_update_action(action)
Expand Down
3 changes: 0 additions & 3 deletions rm-main/src/ui/tabs/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ impl Component for SearchTab {
match action {
UpdateAction::SearchStarted => {
self.search_result_info.searching(ThrobberState::default());
self.ctx.send_action(Action::Render);
}
UpdateAction::SearchResults(magnets) => {
if magnets.is_empty() {
Expand All @@ -192,15 +191,13 @@ impl Component for SearchTab {
self.search_result_info.found(magnets.len());
}
self.table.set_items(magnets);
self.ctx.send_action(Action::Render);
}
_ => (),
}
}

fn tick(&mut self) {
self.search_result_info.tick();
self.ctx.send_action(Action::Render);
}

fn render(&mut self, f: &mut Frame, rect: Rect) {
Expand Down
4 changes: 0 additions & 4 deletions rm-main/src/ui/tabs/torrents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,17 @@ impl Component for TorrentsTab {
match action {
UpdateAction::SessionStats(stats) => {
self.bottom_stats.set_stats(stats);
self.ctx.send_action(Action::Render);
}
UpdateAction::FreeSpace(free_space) => {
self.bottom_stats.set_free_space(free_space);
self.ctx.send_action(Action::Render);
}
UpdateAction::SearchFilterApply(filter) => {
self.table_manager.filter.replace(filter);
self.table_manager.table.state.borrow_mut().select(Some(0));
self.ctx.send_action(Action::Render);
}
UpdateAction::SearchFilterClear => {
self.table_manager.filter = None;
self.table_manager.table.state.borrow_mut().select(Some(0));
self.ctx.send_action(Action::Render);
}
UpdateAction::UpdateTorrents(torrents) => {
self.table_manager.set_new_rows(torrents);
Expand Down
1 change: 0 additions & 1 deletion rm-main/src/ui/tabs/torrents/popups/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ impl Component for FilesPopup {
let new_tree = Node::new_from_torrent(&torrent);
self.torrent = Some(torrent);
self.tree = new_tree;
self.ctx.send_action(Action::Render);
}
}

Expand Down

0 comments on commit 54ed6f3

Please sign in to comment.