refactor: Added accessor methods to servarr_data structs, replaced for loops with functional iterator chains, eliminated mutable state tracking, and updated network module to use get_or_insert_default() for modal options

This commit is contained in:
2025-12-04 10:02:32 -07:00
parent cba53e0841
commit a0073b65ad
10 changed files with 109 additions and 197 deletions
+9 -16
View File
@@ -101,22 +101,15 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
.get_by_left(&movie.quality_profile_id)
.expect("Quality profile ID must exist in quality_profile_map")
.to_owned();
let empty_tag = String::new();
let tags = if !movie.tags.is_empty() {
movie
.tags
.iter()
.map(|tag_id| {
tags_map
.get_by_left(&tag_id.as_i64().expect("Tag ID must be a valid i64"))
.unwrap_or(&empty_tag)
.clone()
})
.collect::<Vec<String>>()
.join(", ")
} else {
String::new()
};
let tags = movie
.tags
.iter()
.filter_map(|tag_id| {
let id = tag_id.as_i64()?;
tags_map.get_by_left(&id).cloned()
})
.collect::<Vec<_>>()
.join(", ");
decorate_with_row_style(
downloads_vec,
+9 -16
View File
@@ -112,22 +112,15 @@ fn draw_library(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
.get_by_left(&series.language_profile_id)
.expect("Language profile ID must exist in language_profile_map")
.to_owned();
let empty_tag = String::new();
let tags = if !series.tags.is_empty() {
series
.tags
.iter()
.map(|tag_id| {
tags_map
.get_by_left(&tag_id.as_i64().expect("Tag ID must be a valid i64"))
.unwrap_or(&empty_tag)
.clone()
})
.collect::<Vec<String>>()
.join(", ")
} else {
String::new()
};
let tags = series
.tags
.iter()
.filter_map(|tag_id| {
let id = tag_id.as_i64()?;
tags_map.get_by_left(&id).cloned()
})
.collect::<Vec<_>>()
.join(", ");
decorate_series_row_with_style(
series,