Terminal interface to find, download, and stream movies, TV shows, and live TV using local media players.
fix(overlay): support multiline notifications and sanitize download directory paths
Samir Hossainsc9b2ca4e951e
diff --git a/src/tui/app/search.rs b/src/tui/app/search.rsindex 686a68a..397902d 100644--- a/src/tui/app/search.rs+++ b/src/tui/app/search.rs@@ -189,24 +189,15 @@ impl App {if raw_arg.is_empty() {let current = if let Some(ref custom) = self.state.download_dir {- custom.to_string_lossy().to_string()+ crate::logging::sanitize_path(custom)} else {let default_base = dirs::download_dir().or_else(|| dirs::home_dir().map(|h| h.join("Downloads"))).unwrap_or_else(|| std::path::PathBuf::from("."));- default_base- .join("MovieBox-TUI")- .to_string_lossy()- .to_string()+ crate::logging::sanitize_path(default_base.join("MovieBox-TUI"))};- self.state.notify(- NotificationKind::Info,- "Download Directory",- format!(- "{}\nSet: /download-dir <path> | Reset: /download-dir reset",- current- ),- );+ self.state+ .notify(NotificationKind::Info, "Download Directory", current);return Some(true);}@@ -215,7 +206,7 @@ impl App {self.state.notify(NotificationKind::Info,"Download Directory",- "Already using system default (Downloads/MovieBox-TUI)",+ "Already using system default (~/Downloads/MovieBox-TUI)",);} else {self.state.download_dir = None;@@ -223,7 +214,7 @@ impl App {self.state.notify(NotificationKind::Success,"Download Directory",- "Reset to default (Downloads/MovieBox-TUI)",+ "Reset to default (~/Downloads/MovieBox-TUI)",);}return Some(true);diff --git a/src/tui/overlay.rs b/src/tui/overlay.rsindex 166f720..eb69916 100644--- a/src/tui/overlay.rs+++ b/src/tui/overlay.rs@@ -267,23 +267,34 @@ pub fn notifications(let has_message =!notification.message.is_empty() && notification.message != notification.title;- let max_content_w = (area.width.saturating_sub(8) as usize).clamp(24, 48);- let message = middle_truncate(¬ification.message, max_content_w);- let title_w = crate::tui::text::width(¬ification.title).saturating_add(6);- let msg_w = if has_message {- crate::tui::text::width(&message).saturating_add(6)+ let max_content_w = (area.width.saturating_sub(8) as usize).clamp(24, 52);+ let msg_lines: Vec<String> = if has_message {+ notification+ .message+ .lines()+ .take(3)+ .map(|line| middle_truncate(line.trim(), max_content_w))+ .filter(|line| !line.is_empty())+ .collect()} else {- 0+ Vec::new()};++ let title_w = crate::tui::text::width(¬ification.title).saturating_add(6);+ let msg_w = msg_lines+ .iter()+ .map(|line| crate::tui::text::width(line).saturating_add(6))+ .max()+ .unwrap_or(0);let badge_w = badge.len().saturating_add(4);let width = title_w.max(msg_w).max(badge_w)- .clamp(28, 52)+ .clamp(28, 56).min(area.width.saturating_sub(4) as usize) as u16;- let height = if has_message { 4 } else { 3 };+ let height = 2 + 1 + msg_lines.len() as u16;if width < 10 || y < area.y.saturating_add(height) {break;@@ -306,9 +317,9 @@ pub fn notifications(theme.text.add_modifier(Modifier::BOLD),)]));- if has_message {+ for line in &msg_lines {lines.push(Line::from(vec![Span::styled(- crate::tui::text::truncate_width(&message, width.saturating_sub(4) as usize),+ crate::tui::text::truncate_width(line, width.saturating_sub(4) as usize),theme.subtext1,)]));}