refactor: Refactored to use more idiomatic let-else statements where applicable
This commit is contained in:
@@ -158,27 +158,23 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
||||
}
|
||||
|
||||
fn is_ready(&self) -> bool {
|
||||
if let Some(movie_details_modal) = &self.app.data.radarr_data.movie_details_modal {
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::MovieDetails => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_details.is_empty()
|
||||
}
|
||||
ActiveRadarrBlock::MovieHistory => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_history.is_empty()
|
||||
}
|
||||
ActiveRadarrBlock::Cast => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_cast.is_empty()
|
||||
}
|
||||
ActiveRadarrBlock::Crew => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_crew.is_empty()
|
||||
}
|
||||
ActiveRadarrBlock::ManualSearch => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_releases.is_empty()
|
||||
}
|
||||
_ => !self.app.is_loading,
|
||||
let Some(movie_details_modal) = &self.app.data.radarr_data.movie_details_modal else {
|
||||
return false;
|
||||
};
|
||||
|
||||
match self.active_radarr_block {
|
||||
ActiveRadarrBlock::MovieDetails => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_details.is_empty()
|
||||
}
|
||||
} else {
|
||||
false
|
||||
ActiveRadarrBlock::MovieHistory => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_history.is_empty()
|
||||
}
|
||||
ActiveRadarrBlock::Cast => !self.app.is_loading && !movie_details_modal.movie_cast.is_empty(),
|
||||
ActiveRadarrBlock::Crew => !self.app.is_loading && !movie_details_modal.movie_crew.is_empty(),
|
||||
ActiveRadarrBlock::ManualSearch => {
|
||||
!self.app.is_loading && !movie_details_modal.movie_releases.is_empty()
|
||||
}
|
||||
_ => !self.app.is_loading,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -110,23 +110,23 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
|
||||
}
|
||||
|
||||
fn is_ready(&self) -> bool {
|
||||
!self.app.is_loading
|
||||
&& if let Some(season_details_modal) = self.app.data.sonarr_data.season_details_modal.as_ref()
|
||||
{
|
||||
if let Some(episode_details_modal) = &season_details_modal.episode_details_modal {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::EpisodeHistory => !episode_details_modal.episode_history.is_empty(),
|
||||
ActiveSonarrBlock::ManualEpisodeSearch => {
|
||||
!episode_details_modal.episode_releases.is_empty()
|
||||
}
|
||||
_ => true,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if self.app.is_loading {
|
||||
return false;
|
||||
}
|
||||
|
||||
let Some(season_details_modal) = self.app.data.sonarr_data.season_details_modal.as_ref() else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let Some(episode_details_modal) = &season_details_modal.episode_details_modal else {
|
||||
return false;
|
||||
};
|
||||
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::EpisodeHistory => !episode_details_modal.episode_history.is_empty(),
|
||||
ActiveSonarrBlock::ManualEpisodeSearch => !episode_details_modal.episode_releases.is_empty(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {}
|
||||
|
||||
@@ -162,17 +162,20 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeasonDetailsHandler
|
||||
}
|
||||
|
||||
fn is_ready(&self) -> bool {
|
||||
!self.app.is_loading
|
||||
&& if let Some(season_details_modal) = &self.app.data.sonarr_data.season_details_modal {
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::SeasonDetails => !season_details_modal.episodes.is_empty(),
|
||||
ActiveSonarrBlock::SeasonHistory => !season_details_modal.season_history.is_empty(),
|
||||
ActiveSonarrBlock::ManualSeasonSearch => !season_details_modal.season_releases.is_empty(),
|
||||
_ => true,
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
if self.app.is_loading {
|
||||
return false;
|
||||
}
|
||||
|
||||
let Some(season_details_modal) = &self.app.data.sonarr_data.season_details_modal else {
|
||||
return false;
|
||||
};
|
||||
|
||||
match self.active_sonarr_block {
|
||||
ActiveSonarrBlock::SeasonDetails => !season_details_modal.episodes.is_empty(),
|
||||
ActiveSonarrBlock::SeasonHistory => !season_details_modal.season_history.is_empty(),
|
||||
ActiveSonarrBlock::ManualSeasonSearch => !season_details_modal.season_releases.is_empty(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_scroll_up(&mut self) {}
|
||||
|
||||
Reference in New Issue
Block a user