From 9f6e6327c5b227a833405758293eb10d69f6276a Mon Sep 17 00:00:00 2001 From: Felipe Contreras Salinas Date: Sun, 15 Jun 2025 00:44:13 -0400 Subject: [PATCH] feat(tui): show IG urls as @username --- src/tui/ui.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/tui/ui.rs b/src/tui/ui.rs index 15090db..33a0782 100644 --- a/src/tui/ui.rs +++ b/src/tui/ui.rs @@ -95,7 +95,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) { p.address.clone(), p.open_hours.clone(), p.description.clone(), - p.url.clone().unwrap_or_default(), + url(p.url.as_ref().map(|u| u.as_ref())), ]) }); @@ -108,6 +108,7 @@ fn list_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) { Constraint::Fill(1), Constraint::Fill(1), Constraint::Fill(1), + Constraint::Fill(1), ]; let places_table = Table::new(places, widths) @@ -176,6 +177,23 @@ fn footer_draw(state: &mut State, f: &mut Frame<'_>, area: Rect) { f.render_widget(keybindings, area); } +fn url(url: Option<&str>) -> String { + match url { + Some(url) => { + if url.starts_with("https://instagram.com/") { + format!( + "@{}", + url.trim_start_matches("https://instagram.com/") + .trim_end_matches("/") + ) + } else { + url.to_owned() + } + } + None => String::new(), + } +} + fn keybinding(key: &'static str, action: &'static str) -> [Span<'static>; 5] { let black_bold = Style::new().black().on_gray().bold(); let red_bold = Style::new().red().on_gray().bold();