Refactored unnecessary data fields into Options to make the code cleaner, and to reduce the memory usage of the application
This commit is contained in:
+17
-19
@@ -177,25 +177,23 @@ impl<'a> App<'a> {
|
||||
}
|
||||
|
||||
async fn populate_movie_collection_table(&mut self) {
|
||||
let collection_movies = if !self.data.radarr_data.filtered_collections.items.is_empty() {
|
||||
self
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.current_selection()
|
||||
.clone()
|
||||
.movies
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
self
|
||||
.data
|
||||
.radarr_data
|
||||
.collections
|
||||
.current_selection()
|
||||
.clone()
|
||||
.movies
|
||||
.unwrap_or_default()
|
||||
};
|
||||
let collection_movies =
|
||||
if let Some(filtered_collections) = self.data.radarr_data.filtered_collections.as_ref() {
|
||||
filtered_collections
|
||||
.current_selection()
|
||||
.clone()
|
||||
.movies
|
||||
.unwrap_or_default()
|
||||
} else {
|
||||
self
|
||||
.data
|
||||
.radarr_data
|
||||
.collections
|
||||
.current_selection()
|
||||
.clone()
|
||||
.movies
|
||||
.unwrap_or_default()
|
||||
};
|
||||
self
|
||||
.data
|
||||
.radarr_data
|
||||
|
||||
@@ -8,6 +8,7 @@ mod tests {
|
||||
use crate::app::App;
|
||||
use crate::models::radarr_models::{Collection, CollectionMovie, Credit, Release};
|
||||
use crate::models::servarr_data::radarr::modals::MovieDetailsModal;
|
||||
use crate::models::StatefulTable;
|
||||
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::network::NetworkEvent;
|
||||
@@ -627,14 +628,12 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_populate_movie_collection_table_filtered() {
|
||||
let mut app = App::default();
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.set_items(vec![Collection {
|
||||
movies: Some(vec![CollectionMovie::default()]),
|
||||
..Collection::default()
|
||||
}]);
|
||||
let mut filtered_collections = StatefulTable::default();
|
||||
filtered_collections.set_items(vec![Collection {
|
||||
movies: Some(vec![CollectionMovie::default()]),
|
||||
..Collection::default()
|
||||
}]);
|
||||
app.data.radarr_data.filtered_collections = Some(filtered_collections);
|
||||
|
||||
app.populate_movie_collection_table().await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user