Refactored table filtering and searching so that they are now relative to the table being filtered/searched on. Also created two new widgets for error messages and popups to make life easier moving forward. Going to refactor table sorting into StatefulTable's as well so all tables can be searched, filtered, and sorted moving forwards.
This commit is contained in:
@@ -1433,7 +1433,7 @@ impl<'a, 'b> Network<'a, 'b> {
|
||||
.await
|
||||
.data
|
||||
.radarr_data
|
||||
.search
|
||||
.add_movie_search
|
||||
.clone()
|
||||
.ok_or(anyhow!("Encountered a race condition"));
|
||||
|
||||
@@ -1711,65 +1711,22 @@ impl<'a, 'b> Network<'a, 'b> {
|
||||
|
||||
async fn extract_movie_id(&mut self) -> (i64, i64) {
|
||||
let app = self.app.lock().await;
|
||||
if app.data.radarr_data.filtered_movies.is_some() {
|
||||
(
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.id,
|
||||
app
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_movies
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.tmdb_id,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
app.data.radarr_data.movies.current_selection().id,
|
||||
app.data.radarr_data.movies.current_selection().tmdb_id,
|
||||
)
|
||||
}
|
||||
(
|
||||
app.data.radarr_data.movies.current_selection().id,
|
||||
app.data.radarr_data.movies.current_selection().tmdb_id,
|
||||
)
|
||||
}
|
||||
|
||||
async fn extract_collection_id(&mut self) -> i64 {
|
||||
if self
|
||||
self
|
||||
.app
|
||||
.lock()
|
||||
.await
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.is_some()
|
||||
{
|
||||
self
|
||||
.app
|
||||
.lock()
|
||||
.await
|
||||
.data
|
||||
.radarr_data
|
||||
.filtered_collections
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.current_selection()
|
||||
.id
|
||||
} else {
|
||||
self
|
||||
.app
|
||||
.lock()
|
||||
.await
|
||||
.data
|
||||
.radarr_data
|
||||
.collections
|
||||
.current_selection()
|
||||
.id
|
||||
}
|
||||
.collections
|
||||
.current_selection()
|
||||
.id
|
||||
}
|
||||
|
||||
async fn append_movie_id_param(&mut self, resource: &str) -> String {
|
||||
|
||||
@@ -454,7 +454,7 @@ mod test {
|
||||
&resource,
|
||||
)
|
||||
.await;
|
||||
app_arc.lock().await.data.radarr_data.search = Some("test term".into());
|
||||
app_arc.lock().await.data.radarr_data.add_movie_search = Some("test term".into());
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new());
|
||||
|
||||
network
|
||||
@@ -520,7 +520,7 @@ mod test {
|
||||
);
|
||||
let (async_server, app_arc, _server) =
|
||||
mock_radarr_api(RequestMethod::Get, None, Some(json!([])), None, &resource).await;
|
||||
app_arc.lock().await.data.radarr_data.search = Some("test term".into());
|
||||
app_arc.lock().await.data.radarr_data.add_movie_search = Some("test term".into());
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new());
|
||||
|
||||
network
|
||||
@@ -2639,12 +2639,12 @@ mod test {
|
||||
async fn test_extract_movie_id_filtered_movies() {
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let mut filtered_movies = StatefulTable::default();
|
||||
filtered_movies.set_items(vec![Movie {
|
||||
filtered_movies.set_filtered_items(vec![Movie {
|
||||
id: 1,
|
||||
tmdb_id: 2,
|
||||
..Movie::default()
|
||||
}]);
|
||||
app_arc.lock().await.data.radarr_data.filtered_movies = Some(filtered_movies);
|
||||
app_arc.lock().await.data.radarr_data.movies = filtered_movies;
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new());
|
||||
|
||||
assert_eq!(network.extract_movie_id().await, (1, 2));
|
||||
@@ -2672,11 +2672,11 @@ mod test {
|
||||
async fn test_extract_collection_id_filtered_collection() {
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let mut filtered_collections = StatefulTable::default();
|
||||
filtered_collections.set_items(vec![Collection {
|
||||
filtered_collections.set_filtered_items(vec![Collection {
|
||||
id: 1,
|
||||
..Collection::default()
|
||||
}]);
|
||||
app_arc.lock().await.data.radarr_data.filtered_collections = Some(filtered_collections);
|
||||
app_arc.lock().await.data.radarr_data.collections = filtered_collections;
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new());
|
||||
|
||||
assert_eq!(network.extract_collection_id().await, 1);
|
||||
|
||||
Reference in New Issue
Block a user