Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Do not quit on new issue form
Erik Kundt committed 2 years ago
commit 33eaa4e8e0e57529d95cf199242e2bf8761508e4
parent a827e22796e0d57bd050d0ccffdc2adc70a0ff40
3 files changed +19 -17
modified src/app.rs
@@ -11,7 +11,7 @@ use radicle::profile::Profile;

use radicle_tui::ui::widget;
use tuirealm::application::PollStrategy;
-
use tuirealm::{Application, Frame, NoUserEvent};
+
use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause};

use radicle_tui::ui::context::Context;
use radicle_tui::ui::theme::{self, Theme};
@@ -288,7 +288,11 @@ impl Tui<Cid, Message> for App {

        // Add global key listener and subscribe to key events
        let global = ui::widget::common::global_listener().to_boxed();
-
        app.mount(Cid::GlobalListener, global, subscription::global())?;
+
        app.mount(
+
            Cid::GlobalListener,
+
            global,
+
            vec![Sub::new(subscription::global_clause(), SubClause::Always)],
+
        )?;

        Ok(())
    }
modified src/app/page.rs
@@ -478,6 +478,8 @@ impl ViewPage for IssuePage {
                    app.remount(Cid::Issue(cid.clone()), new_form, vec![])?;
                    app.active(&Cid::Issue(cid.clone()))?;

+
                    app.unsubscribe(&Cid::GlobalListener, subscription::global_clause())?;
+

                    self.update_shortcuts(app, cid)?;
                }
            }
@@ -485,6 +487,11 @@ impl ViewPage for IssuePage {
                app.blur()?;
                app.umount(&Cid::Issue(cid))?;

+
                app.subscribe(
+
                    &Cid::GlobalListener,
+
                    Sub::new(subscription::global_clause(), SubClause::Always),
+
                )?;
+

                self.update_shortcuts(app, IssueCid::List)?;
            }
            _ => {}
modified src/app/subscription.rs
@@ -1,7 +1,5 @@
-
use std::hash::Hash;
-

use tuirealm::event::{Key, KeyEvent, KeyModifiers};
-
use tuirealm::{Sub, SubClause, SubEventClause};
+
use tuirealm::SubEventClause;

pub fn navigation_clause<UserEvent>() -> SubEventClause<UserEvent>
where
@@ -13,19 +11,12 @@ where
    })
}

-
pub fn global<Id, UserEvent>() -> Vec<Sub<Id, UserEvent>>
+
pub fn global_clause<UserEvent>() -> SubEventClause<UserEvent>
where
-
    Id: Clone + Hash + Eq + PartialEq,
    UserEvent: Clone + Eq + PartialEq + PartialOrd,
{
-
    vec![
-
        Sub::new(
-
            SubEventClause::Keyboard(KeyEvent {
-
                code: Key::Char('q'),
-
                modifiers: KeyModifiers::NONE,
-
            }),
-
            SubClause::Always,
-
        ),
-
        Sub::new(SubEventClause::WindowResize, SubClause::Always),
-
    ]
+
    SubEventClause::Keyboard(KeyEvent {
+
        code: Key::Char('q'),
+
        modifiers: KeyModifiers::NONE,
+
    })
}