fix: Wrapped all Sonarr use of Language with Option to fix the 'null' array issue in the new Sonarr API

This commit is contained in:
2025-12-13 13:06:33 -07:00
parent 9599ac28ca
commit 9c1a9cc3c5
17 changed files with 139 additions and 49 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ fn draw_blocklist_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
let title = series_title.as_ref().unwrap_or(&String::new()).to_owned();
let languages_string = languages
.iter()
.map(|lang| lang.name.to_owned())
.map(|lang| lang.as_ref().unwrap_or(&Default::default()).name.to_owned())
.collect::<Vec<String>>()
.join(", ");
+8 -1
View File
@@ -1,5 +1,6 @@
use crate::app::App;
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, HISTORY_BLOCKS};
use crate::models::servarr_models::Language;
use crate::models::sonarr_models::{SonarrHistoryEventType, SonarrHistoryItem};
use crate::models::Route;
use crate::ui::styles::ManagarrStyle;
@@ -77,7 +78,13 @@ fn draw_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
Cell::from(
languages
.iter()
.map(|language| language.name.to_owned())
.map(|language| {
language
.as_ref()
.unwrap_or(&Language::default())
.name
.to_owned()
})
.collect::<Vec<String>>()
.join(","),
),
+13 -2
View File
@@ -1,5 +1,6 @@
use crate::app::App;
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS};
use crate::models::servarr_models::Language;
use crate::models::sonarr_models::{
DownloadRecord, DownloadStatus, Episode, SonarrHistoryEventType, SonarrHistoryItem, SonarrRelease,
};
@@ -280,7 +281,13 @@ fn draw_episode_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect)
Cell::from(
languages
.iter()
.map(|language| language.name.to_owned())
.map(|language| {
language
.as_ref()
.unwrap_or(&Language::default())
.name
.to_owned()
})
.collect::<Vec<String>>()
.join(","),
),
@@ -441,7 +448,11 @@ fn draw_episode_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
};
let language = if languages.is_some() {
languages.clone().unwrap()[0].name.clone()
languages.clone().unwrap()[0]
.as_ref()
.unwrap_or(&Default::default())
.name
.clone()
} else {
String::new()
};
+12 -2
View File
@@ -276,7 +276,13 @@ fn draw_season_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
Cell::from(
languages
.iter()
.map(|language| language.name.to_owned())
.map(|language| {
language
.as_ref()
.unwrap_or(&Default::default())
.name
.to_owned()
})
.collect::<Vec<String>>()
.join(","),
),
@@ -398,7 +404,11 @@ fn draw_season_releases(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
};
let language = if languages.is_some() {
languages.clone().unwrap()[0].name.clone()
languages.clone().unwrap()[0]
.as_ref()
.unwrap_or(&Default::default())
.name
.clone()
} else {
String::new()
};
@@ -324,7 +324,13 @@ fn draw_series_history_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
Cell::from(
languages
.iter()
.map(|language| language.name.to_owned())
.map(|language| {
language
.as_ref()
.unwrap_or(&Default::default())
.name
.to_owned()
})
.collect::<Vec<String>>()
.join(","),
),