fix(ui): Fixed a potential rare bug in the UI where the application would panic if the height of the downloads window is 0.

This commit is contained in:
2024-11-29 16:31:51 -07:00
parent 08f190fc6e
commit 9b2040059d
2 changed files with 4 additions and 6 deletions
+2 -2
View File
@@ -178,8 +178,8 @@ fn draw_downloads_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
if !downloads_vec.is_empty() {
f.render_widget(block, area);
let max_items = (((area.height as f64 / 2.0).floor() * 2.0) as usize) / 2;
let items = cmp::min(downloads_vec.len(), max_items - 1);
let max_items = ((((area.height as f32 / 2.0).floor() * 2.0) as i32) / 2) - 1;
let items = cmp::min(downloads_vec.len(), max_items.unsigned_abs() as usize);
let download_item_areas = Layout::vertical(
iter::repeat(Constraint::Length(2))
.take(items)