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:
@@ -2,7 +2,6 @@ use std::{cmp, iter};
|
||||
|
||||
use chrono::{Duration, Utc};
|
||||
use library::LibraryUi;
|
||||
use log::debug;
|
||||
use ratatui::{
|
||||
layout::{Constraint, Layout, Rect},
|
||||
style::Stylize,
|
||||
@@ -168,10 +167,9 @@ 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);
|
||||
debug!("Items: {items}");
|
||||
let max_items = ((((area.height as f64 / 2.0).floor() * 2.0) as i64) / 2) - 1;
|
||||
let items = cmp::min(downloads_vec.len(), max_items.abs() as usize);
|
||||
let download_item_areas = Layout::vertical(
|
||||
iter::repeat(Constraint::Length(2))
|
||||
.take(items)
|
||||
|
||||
Reference in New Issue
Block a user