fix: Improved the system notification feature so it can persist between modals

This commit is contained in:
2026-02-04 08:18:04 -07:00
parent af573cac2a
commit 5556e48fc0
4 changed files with 26 additions and 9 deletions
+20
View File
@@ -174,6 +174,26 @@ mod tests {
);
}
#[test]
fn test_handle_clear_notification() {
let mut app = App::test_default();
app.notification = Some(Notification::new(
"Test".to_owned(),
"Test".to_owned(),
true,
));
app.push_navigation_stack(ActiveRadarrBlock::Movies.into());
app.push_navigation_stack(ActiveRadarrBlock::MovieDetails.into());
handle_events(DEFAULT_KEYBINDINGS.esc.key, &mut app);
assert_none!(app.notification);
assert_eq!(
app.get_current_route(),
ActiveRadarrBlock::MovieDetails.into()
);
}
#[rstest]
fn test_handle_prompt_toggle_left_right_radarr(#[values(Key::Left, Key::Right)] key: Key) {
let mut app = App::test_default();
+4 -7
View File
@@ -2,11 +2,11 @@ use lidarr_handlers::LidarrHandler;
use radarr_handlers::RadarrHandler;
use sonarr_handlers::SonarrHandler;
use crate::app::App;
use crate::app::context_clues::{
ContextClueProvider, ServarrContextClueProvider, SERVARR_CONTEXT_CLUES,
ContextClueProvider, SERVARR_CONTEXT_CLUES, ServarrContextClueProvider,
};
use crate::app::key_binding::KeyBinding;
use crate::app::App;
use crate::event::Key;
use crate::handlers::keybinding_handler::KeybindingHandler;
use crate::matches_key;
@@ -116,7 +116,8 @@ pub fn handle_events(key: Key, app: &mut App<'_>) {
} else {
app.keymapping_table = None;
}
} else if matches_key!(esc, key) && handle_clear_notification(app) {
} else if matches_key!(esc, key) && app.notification.is_some() {
app.notification.take();
} else {
match app.get_current_route() {
_ if app.keymapping_table.is_some() => {
@@ -184,10 +185,6 @@ fn handle_clear_errors(app: &mut App<'_>) {
}
}
fn handle_clear_notification(app: &mut App<'_>) -> bool {
app.notification.take().is_some()
}
fn handle_prompt_toggle(app: &mut App<'_>, key: Key) {
match key {
_ if matches_key!(left, key) || matches_key!(right, key) => match app.get_current_route() {
@@ -3,7 +3,7 @@ mod tests {
use crate::models::lidarr_models::LidarrReleaseDownloadBody;
use crate::models::servarr_data::Notification;
use crate::network::lidarr_network::LidarrEvent;
use crate::network::network_tests::test_utils::{test_network, MockServarrApi};
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
use pretty_assertions::assert_eq;
use serde_json::json;
@@ -2,7 +2,7 @@
mod tests {
use crate::models::servarr_data::Notification;
use crate::models::sonarr_models::SonarrReleaseDownloadBody;
use crate::network::network_tests::test_utils::{test_network, MockServarrApi};
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
use crate::network::sonarr_network::SonarrEvent;
use pretty_assertions::assert_eq;
use serde_json::json;