fix(sonarr): pass the series ID alongside all TriggerAutomaticSeriesSearch events when publishing to the networking channel
This commit is contained in:
@@ -37,6 +37,7 @@ impl<'a, 'b> SeriesDetailsHandler<'a, 'b> {
|
||||
.expect("Series history is undefined"),
|
||||
SonarrHistoryItem
|
||||
);
|
||||
|
||||
fn extract_series_id_season_number_tuple(&self) -> (i64, i64) {
|
||||
let series_id = self.app.data.sonarr_data.series.current_selection().id;
|
||||
let season_number = self
|
||||
@@ -49,6 +50,10 @@ impl<'a, 'b> SeriesDetailsHandler<'a, 'b> {
|
||||
|
||||
(series_id, season_number)
|
||||
}
|
||||
|
||||
fn extract_series_id(&self) -> i64 {
|
||||
self.app.data.sonarr_data.series.current_selection().id
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler<'a, 'b> {
|
||||
@@ -180,8 +185,9 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
}
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt => {
|
||||
if self.app.data.sonarr_data.prompt_confirm {
|
||||
self.app.data.sonarr_data.prompt_confirm_action =
|
||||
Some(SonarrEvent::TriggerAutomaticSeriesSearch(None));
|
||||
self.app.data.sonarr_data.prompt_confirm_action = Some(
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(self.extract_series_id()),
|
||||
);
|
||||
}
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
@@ -312,8 +318,9 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt => {
|
||||
if key == DEFAULT_KEYBINDINGS.confirm.key {
|
||||
self.app.data.sonarr_data.prompt_confirm = true;
|
||||
self.app.data.sonarr_data.prompt_confirm_action =
|
||||
Some(SonarrEvent::TriggerAutomaticSeriesSearch(None));
|
||||
self.app.data.sonarr_data.prompt_confirm_action = Some(
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(self.extract_series_id()),
|
||||
);
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ mod tests {
|
||||
#[rstest]
|
||||
#[case(
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt,
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(None)
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(1)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt,
|
||||
@@ -195,6 +195,7 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.push_navigation_stack(ActiveSonarrBlock::SeriesDetails.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -567,7 +568,7 @@ mod tests {
|
||||
#[rstest]
|
||||
#[case(
|
||||
ActiveSonarrBlock::AutomaticallySearchSeriesPrompt,
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(None)
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(1)
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt,
|
||||
@@ -581,6 +582,7 @@ mod tests {
|
||||
) {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.prompt_confirm = true;
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
app.push_navigation_stack(active_sonarr_block.into());
|
||||
app.push_navigation_stack(prompt_block.into());
|
||||
|
||||
@@ -629,6 +631,22 @@ mod tests {
|
||||
assert_eq!(series_id_season_number_tuple, (1, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_series_id() {
|
||||
let mut app = App::default();
|
||||
app.data.sonarr_data.series.set_items(vec![series()]);
|
||||
|
||||
let series_id = SeriesDetailsHandler::with(
|
||||
DEFAULT_KEYBINDINGS.esc.key,
|
||||
&mut app,
|
||||
ActiveSonarrBlock::SeriesDetails,
|
||||
None,
|
||||
)
|
||||
.extract_series_id();
|
||||
|
||||
assert_eq!(series_id, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_series_details_handler_is_not_ready_when_loading() {
|
||||
let mut app = App::default();
|
||||
|
||||
Reference in New Issue
Block a user