Skip to content

Commit

Permalink
fix: review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden committed Jun 20, 2024
1 parent ace611d commit 590e3df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 8 additions & 7 deletions rm-main/src/ui/tabs/torrents/bottom_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ impl Component for BottomStats {
let all = stats.torrent_count;
let download = bytes_to_human_format(stats.download_speed);
let upload = bytes_to_human_format(stats.upload_speed);

let mut text = format!(" {all} | ▼ {download} | ▲ {upload}");

let table_manager = &*self.table_manager.lock().unwrap();
let table = table_manager.table.borrow();
if let Some(current) = table.state.borrow().selected() {
let current_idx = current + 1;
text = format!(" {current_idx}/{all} | ▼ {download} | ▲ {upload}");
}

if let Some(free_space) = &*self.free_space.lock().unwrap() {
let free_space = bytes_to_human_format(free_space.size_bytes);
text = format!("󰋊 {free_space} | {text}")
}

let table_manager = &*self.table_manager.lock().unwrap();
let state = table_manager.table.borrow();
if let (Some(current), total) = (state.state.borrow().selected(), state.get_len()) {
let current_idx = current + 1;
text = format!("{current_idx}/{total} | {text}")
}

let paragraph = Paragraph::new(text).alignment(Alignment::Right);
f.render_widget(paragraph, rect);
}
Expand Down
10 changes: 5 additions & 5 deletions rm-main/src/ui/tabs/torrents/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct TorrentsTab {
table_manager: Arc<Mutex<TableManager>>,
popup_manager: PopupManager,
task_manager: TaskManager,
stats: BottomStats,
bottom_stats: BottomStats,
}

impl TorrentsTab {
Expand All @@ -50,7 +50,7 @@ impl TorrentsTab {

tokio::spawn(transmission::fetchers::torrents(
ctx.clone(),
Arc::clone(&bottom_stats.table_manager.clone()),
Arc::clone(&bottom_stats.table_manager),
));

tokio::spawn(transmission::fetchers::free_space(
Expand All @@ -59,7 +59,7 @@ impl TorrentsTab {
));

Self {
stats: bottom_stats,
bottom_stats,
task_manager: TaskManager::new(table_manager.clone(), ctx.clone()),
table_manager,
popup_manager: PopupManager::new(),
Expand All @@ -75,7 +75,7 @@ impl Component for TorrentsTab {

self.render_table(f, torrents_list_rect);

self.stats.render(f, stats_rect);
self.bottom_stats.render(f, stats_rect);

self.task_manager.render(f, stats_rect);

Expand Down Expand Up @@ -159,7 +159,7 @@ impl TorrentsTab {
}

fn show_statistics_popup(&mut self) -> Option<Action> {
if let Some(stats) = &*self.stats.stats.lock().unwrap() {
if let Some(stats) = &*self.bottom_stats.stats.lock().unwrap() {
let popup = StatisticsPopup::new(self.ctx.clone(), stats.clone());
self.popup_manager.show_popup(CurrentPopup::Stats(popup));
Some(Action::Render)
Expand Down

0 comments on commit 590e3df

Please sign in to comment.