fix(handler): Fixed a bug in the history handler that wouldn't reset the filter or search if a user hit 'esc' on the History tab
This commit is contained in:
@@ -845,11 +845,23 @@ mod tests {
|
||||
app.error = "test error".to_owned().into();
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
app.push_navigation_stack(ActiveSonarrBlock::History.into());
|
||||
app.data.sonarr_data = create_test_sonarr_data();
|
||||
app.data.sonarr_data.history = StatefulTable {
|
||||
search: Some("Test".into()),
|
||||
filter: Some("Test".into()),
|
||||
filtered_items: Some(Vec::new()),
|
||||
filtered_state: Some(TableState::default()),
|
||||
..StatefulTable::default()
|
||||
};
|
||||
|
||||
HistoryHandler::with(ESC_KEY, &mut app, ActiveSonarrBlock::History, None).handle();
|
||||
|
||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::History.into());
|
||||
assert!(app.error.text.is_empty());
|
||||
assert_eq!(app.data.sonarr_data.history.search, None);
|
||||
assert_eq!(app.data.sonarr_data.history.filter, None);
|
||||
assert_eq!(app.data.sonarr_data.history.filtered_items, None);
|
||||
assert_eq!(app.data.sonarr_data.history.filtered_state, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use log::debug;
|
||||
|
||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||
use crate::app::App;
|
||||
use crate::event::Key;
|
||||
@@ -250,7 +252,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for HistoryHandler<'a, '
|
||||
ActiveSonarrBlock::HistoryItemDetails | ActiveSonarrBlock::HistorySortPrompt => {
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
_ => handle_clear_errors(self.app),
|
||||
_ => {
|
||||
self.app.data.sonarr_data.history.reset_search();
|
||||
self.app.data.sonarr_data.history.reset_filter();
|
||||
handle_clear_errors(self.app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ mod tests {
|
||||
ActiveSonarrBlock::SeriesSortPrompt,
|
||||
ActiveSonarrBlock::UpdateAllSeriesPrompt,
|
||||
// ActiveSonarrBlock::UpdateAndScanSeriesPrompt
|
||||
// ActiveSonarrBlock::SeriesHistoryDetails,
|
||||
)]
|
||||
active_sonarr_block: ActiveSonarrBlock,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user