Fixed a UI bug that briefly showed "No movies found" error before actually loading content

This commit is contained in:
2023-08-08 10:50:05 -06:00
parent 316c129b99
commit fa381cea01
2 changed files with 19 additions and 7 deletions
+11 -7
View File
@@ -8,8 +8,8 @@ use crate::app::radarr::ActiveRadarrBlock;
use crate::models::radarr_models::AddMovieSearchResult; use crate::models::radarr_models::AddMovieSearchResult;
use crate::models::Route; use crate::models::Route;
use crate::ui::utils::{ use crate::ui::utils::{
borderless_block, get_width_with_margin, horizontal_chunks, layout_block, borderless_block, centered_rect, get_width_with_margin, horizontal_chunks, layout_block,
layout_paragraph_borderless, show_cursor, style_default, style_failure, style_help, layout_error_paragraph, layout_paragraph_borderless, show_cursor, style_default, style_help,
style_primary, title_block_centered, vertical_chunks_with_margin, style_primary, title_block_centered, vertical_chunks_with_margin,
}; };
use crate::ui::{ use crate::ui::{
@@ -91,11 +91,15 @@ fn draw_add_movie_search<B: Backend>(f: &mut Frame<'_, B>, app: &mut App, area:
.alignment(Alignment::Center); .alignment(Alignment::Center);
f.render_widget(help_paragraph, chunks[2]); f.render_widget(help_paragraph, chunks[2]);
if app.data.radarr_data.add_searched_movies.items.is_empty() && !app.is_loading { if app.data.radarr_data.add_searched_movies.items.is_empty()
let mut error_text = Text::from("No movies found matching your query!"); && !app.is_loading
error_text.patch_style(style_failure()); && !app.is_routing
let error_paragraph = Paragraph::new(error_text).block(layout_block()); {
f.render_widget(error_paragraph, chunks[1]); 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 { } else {
draw_table( draw_table(
f, f,
+8
View File
@@ -93,6 +93,14 @@ pub fn layout_paragraph_borderless(string: &str) -> Paragraph {
.alignment(Alignment::Center) .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> { pub fn borderless_block<'a>() -> Block<'a> {
Block::default() Block::default()
} }