Do not quit on new issue form

This commit is contained in:
Erik Kundt
2023-08-11 11:44:35 +02:00
parent a827e22796
commit 33eaa4e8e0
3 changed files with 19 additions and 17 deletions
+6 -2
View File
@@ -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(())
}
+7
View File
@@ -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)?;
}
_ => {}
+6 -15
View File
@@ -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,
})
}