feat: Support alternative keymappings for all keys, featuring hjkl movements

This commit is contained in:
2025-03-17 22:02:15 -06:00
parent c633347ecc
commit 0048d71b74
77 changed files with 1247 additions and 304 deletions
@@ -1,13 +1,12 @@
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
use crate::app::App;
use crate::event::Key;
use crate::handle_table_events;
use crate::handlers::sonarr_handlers::library::season_details_handler::releases_sorting_options;
use crate::handlers::table_handler::TableHandlingConfig;
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, EPISODE_DETAILS_BLOCKS};
use crate::models::sonarr_models::{SonarrHistoryItem, SonarrRelease, SonarrReleaseDownloadBody};
use crate::network::sonarr_network::SonarrEvent;
use crate::{handle_table_events, matches_key};
#[cfg(test)]
#[path = "episode_details_handler_tests.rs"]
@@ -88,6 +87,10 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
EPISODE_DETAILS_BLOCKS.contains(&active_block)
}
fn ignore_alt_navigation(&self) -> bool {
self.app.should_ignore_quit_key
}
fn new(
key: Key,
app: &'a mut App<'b>,
@@ -142,7 +145,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
| ActiveSonarrBlock::EpisodeHistory
| ActiveSonarrBlock::EpisodeFile
| ActiveSonarrBlock::ManualEpisodeSearch => match self.key {
_ if self.key == DEFAULT_KEYBINDINGS.left.key => {
_ if matches_key!(left, self.key) => {
self
.app
.data
@@ -170,7 +173,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
.get_active_route(),
);
}
_ if self.key == DEFAULT_KEYBINDINGS.right.key => {
_ if matches_key!(right, self.key) => {
self
.app
.data
@@ -306,21 +309,19 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
| ActiveSonarrBlock::EpisodeHistory
| ActiveSonarrBlock::EpisodeFile
| ActiveSonarrBlock::ManualEpisodeSearch => match self.key {
_ if self.key == DEFAULT_KEYBINDINGS.refresh.key => {
_ if matches_key!(refresh, self.key) => {
self
.app
.pop_and_push_navigation_stack(self.active_sonarr_block.into());
}
_ if self.key == DEFAULT_KEYBINDINGS.auto_search.key => {
_ if matches_key!(auto_search, self.key) => {
self
.app
.push_navigation_stack(ActiveSonarrBlock::AutomaticallySearchEpisodePrompt.into());
}
_ => (),
},
ActiveSonarrBlock::AutomaticallySearchEpisodePrompt
if key == DEFAULT_KEYBINDINGS.confirm.key =>
{
ActiveSonarrBlock::AutomaticallySearchEpisodePrompt if matches_key!(confirm, key) => {
self.app.data.sonarr_data.prompt_confirm = true;
self.app.data.sonarr_data.prompt_confirm_action = Some(
SonarrEvent::TriggerAutomaticEpisodeSearch(self.extract_episode_id()),
@@ -328,9 +329,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for EpisodeDetailsHandle
self.app.pop_navigation_stack();
}
ActiveSonarrBlock::ManualEpisodeSearchConfirmPrompt
if key == DEFAULT_KEYBINDINGS.confirm.key =>
{
ActiveSonarrBlock::ManualEpisodeSearchConfirmPrompt if matches_key!(confirm, key) => {
if self.app.data.sonarr_data.prompt_confirm {
let SonarrRelease {
guid, indexer_id, ..