fix(sonarr): Corrected a bug that would cause a crash if a user spams the ESC key while searching for a new series and the search results are still loading

This commit is contained in:
2024-12-17 22:45:34 -07:00
parent fedb78fb88
commit acf983c07c
2 changed files with 16 additions and 1 deletions
@@ -6,6 +6,7 @@ use crate::models::servarr_data::sonarr::sonarr_data::{
ActiveSonarrBlock, ADD_SERIES_BLOCKS, ADD_SERIES_SELECTION_BLOCKS,
};
use crate::models::sonarr_models::{AddSeriesBody, AddSeriesOptions, AddSeriesSearchResult};
use crate::models::stateful_table::StatefulTable;
use crate::models::{BlockSelectionState, Scrollable};
use crate::network::sonarr_network::SonarrEvent;
use crate::{handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, App, Key};
@@ -31,7 +32,7 @@ impl<'a, 'b> AddSeriesHandler<'a, 'b> {
.sonarr_data
.add_searched_series
.as_mut()
.unwrap(),
.unwrap_or(&mut StatefulTable::default()),
AddSeriesSearchResult
);
@@ -1714,6 +1714,20 @@ mod tests {
});
}
#[test]
fn test_add_series_search_no_panic_on_none_search_result() {
let mut app = App::default();
app.data.sonarr_data.add_series_search = None;
AddSeriesHandler::with(
DEFAULT_KEYBINDINGS.esc.key,
&mut app,
ActiveSonarrBlock::AddSeriesSearchResults,
None,
)
.handle();
}
#[test]
fn test_build_add_series_body() {
let mut app = App::default();