Skip to content

Commit

Permalink
Merge pull request #27 from Dark-Alex-17/race-condition-refactor
Browse files Browse the repository at this point in the history
Race condition refactor
  • Loading branch information
Dark-Alex-17 authored Dec 19, 2024
2 parents 368d5d3 + 12fba15 commit e602b66
Show file tree
Hide file tree
Showing 97 changed files with 5,559 additions and 6,562 deletions.
3 changes: 3 additions & 0 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e

echo "Running pre-push hook:"

echo "Executing: cargo fmt"
cargo fmt

echo "Executing: make lint"
make lint

Expand Down
3 changes: 3 additions & 0 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -e

echo "Running pre-push hook:"

echo "Executing: cargo fmt --check"
cargo fmt --check

echo "Executing: make lint"
make lint

Expand Down
49 changes: 42 additions & 7 deletions src/app/radarr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ impl<'a> App<'a> {
}
ActiveRadarrBlock::TestIndexer => {
self
.dispatch_network_event(RadarrEvent::TestIndexer(None).into())
.dispatch_network_event(
RadarrEvent::TestIndexer(self.extract_radarr_indexer_id().await).into(),
)
.await;
}
ActiveRadarrBlock::TestAllIndexers => {
Expand All @@ -93,7 +95,7 @@ impl<'a> App<'a> {
.dispatch_network_event(RadarrEvent::GetQueuedEvents.into())
.await;
self
.dispatch_network_event(RadarrEvent::GetLogs(None).into())
.dispatch_network_event(RadarrEvent::GetLogs(500).into())
.await;
}
ActiveRadarrBlock::SystemUpdates => {
Expand All @@ -103,17 +105,23 @@ impl<'a> App<'a> {
}
ActiveRadarrBlock::AddMovieSearchResults => {
self
.dispatch_network_event(RadarrEvent::SearchNewMovie(None).into())
.dispatch_network_event(
RadarrEvent::SearchNewMovie(self.extract_movie_search_query().await).into(),
)
.await;
}
ActiveRadarrBlock::MovieDetails | ActiveRadarrBlock::FileInfo => {
self
.dispatch_network_event(RadarrEvent::GetMovieDetails(None).into())
.dispatch_network_event(
RadarrEvent::GetMovieDetails(self.extract_movie_id().await).into(),
)
.await;
}
ActiveRadarrBlock::MovieHistory => {
self
.dispatch_network_event(RadarrEvent::GetMovieHistory(None).into())
.dispatch_network_event(
RadarrEvent::GetMovieHistory(self.extract_movie_id().await).into(),
)
.await;
}
ActiveRadarrBlock::Cast | ActiveRadarrBlock::Crew => {
Expand All @@ -123,7 +131,9 @@ impl<'a> App<'a> {
|| movie_details_modal.movie_crew.items.is_empty() =>
{
self
.dispatch_network_event(RadarrEvent::GetMovieCredits(None).into())
.dispatch_network_event(
RadarrEvent::GetMovieCredits(self.extract_movie_id().await).into(),
)
.await;
}
_ => (),
Expand All @@ -132,7 +142,7 @@ impl<'a> App<'a> {
ActiveRadarrBlock::ManualSearch => match self.data.radarr_data.movie_details_modal.as_ref() {
Some(movie_details_modal) if movie_details_modal.movie_releases.items.is_empty() => {
self
.dispatch_network_event(RadarrEvent::GetReleases(None).into())
.dispatch_network_event(RadarrEvent::GetReleases(self.extract_movie_id().await).into())
.await;
}
_ => (),
Expand Down Expand Up @@ -219,4 +229,29 @@ impl<'a> App<'a> {
.collection_movies
.set_items(collection_movies);
}

async fn extract_movie_id(&self) -> i64 {
self.data.radarr_data.movies.current_selection().clone().id
}

async fn extract_movie_search_query(&self) -> String {
self
.data
.radarr_data
.add_movie_search
.as_ref()
.expect("Add movie search is empty")
.text
.clone()
}

async fn extract_radarr_indexer_id(&self) -> i64 {
self
.data
.radarr_data
.indexers
.current_selection()
.clone()
.id
}
}
Loading

0 comments on commit e602b66

Please sign in to comment.