From fa381cea01f98f738ddefc518b262a55c9bd4cdb Mon Sep 17 00:00:00 2001 From: Dark-Alex-17 Date: Tue, 8 Aug 2023 10:50:05 -0600 Subject: [PATCH] Fixed a UI bug that briefly showed "No movies found" error before actually loading content --- src/ui/radarr_ui/add_movie_ui.rs | 18 +++++++++++------- src/ui/utils.rs | 8 ++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/ui/radarr_ui/add_movie_ui.rs b/src/ui/radarr_ui/add_movie_ui.rs index bccb8c2..c097ef3 100644 --- a/src/ui/radarr_ui/add_movie_ui.rs +++ b/src/ui/radarr_ui/add_movie_ui.rs @@ -8,8 +8,8 @@ use crate::app::radarr::ActiveRadarrBlock; use crate::models::radarr_models::AddMovieSearchResult; use crate::models::Route; use crate::ui::utils::{ - borderless_block, get_width_with_margin, horizontal_chunks, layout_block, - layout_paragraph_borderless, show_cursor, style_default, style_failure, style_help, + borderless_block, centered_rect, get_width_with_margin, horizontal_chunks, layout_block, + layout_error_paragraph, layout_paragraph_borderless, show_cursor, style_default, style_help, style_primary, title_block_centered, vertical_chunks_with_margin, }; use crate::ui::{ @@ -91,11 +91,15 @@ fn draw_add_movie_search(f: &mut Frame<'_, B>, app: &mut App, area: .alignment(Alignment::Center); f.render_widget(help_paragraph, chunks[2]); - if app.data.radarr_data.add_searched_movies.items.is_empty() && !app.is_loading { - let mut error_text = Text::from("No movies found matching your query!"); - error_text.patch_style(style_failure()); - let error_paragraph = Paragraph::new(error_text).block(layout_block()); - f.render_widget(error_paragraph, chunks[1]); + if app.data.radarr_data.add_searched_movies.items.is_empty() + && !app.is_loading + && !app.is_routing + { + f.render_widget(layout_block(), chunks[1]); + f.render_widget( + layout_error_paragraph("No movies found matching your query!"), + centered_rect(30, 10, chunks[1]), + ); } else { draw_table( f, diff --git a/src/ui/utils.rs b/src/ui/utils.rs index ac1c33a..5d73992 100644 --- a/src/ui/utils.rs +++ b/src/ui/utils.rs @@ -93,6 +93,14 @@ pub fn layout_paragraph_borderless(string: &str) -> Paragraph { .alignment(Alignment::Center) } +pub fn layout_error_paragraph(string: &str) -> Paragraph { + Paragraph::new(Text::from(string)) + .block(layout_block_with_title(title_style("Error"))) + .style(style_failure().add_modifier(Modifier::BOLD)) + .wrap(Wrap { trim: false }) + .alignment(Alignment::Center) +} + pub fn borderless_block<'a>() -> Block<'a> { Block::default() }