mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-29 06:20:28 +08:00
issue/list: Fix wrong events being sent globally
This commit is contained in:
@@ -244,8 +244,8 @@ pub async fn run(options: Options, ctx: impl Context) -> anyhow::Result<()> {
|
||||
IssueOperation::Edit { id } => {
|
||||
terminal::run_rad(
|
||||
Some("issue"),
|
||||
&["edit".into(), id.to_string().into()],
|
||||
Quiet::Yes,
|
||||
&["edit".into(), id.to_string().into(), "--quiet".into()],
|
||||
Quiet::No,
|
||||
)?;
|
||||
}
|
||||
IssueOperation::Comment {
|
||||
|
||||
+18
-10
@@ -514,16 +514,24 @@ fn browser(channel: &Channel<Message>) -> Widget<State, Message> {
|
||||
Browser::new(tx.clone())
|
||||
.to_widget(tx.clone())
|
||||
.on_update(|state| BrowserProps::from(state).to_boxed_any().into())
|
||||
.on_event(|event, _, _| {
|
||||
if let Event::Key(key) = event {
|
||||
match key {
|
||||
Key::Enter => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::Show),
|
||||
}),
|
||||
Key::Char('e') => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::Edit),
|
||||
}),
|
||||
_ => None,
|
||||
.on_event(|event, _, props| {
|
||||
let default = BrowserProps::default();
|
||||
let props = props
|
||||
.and_then(|props| props.inner_ref::<BrowserProps>())
|
||||
.unwrap_or(&default);
|
||||
if !props.show_search() {
|
||||
if let Event::Key(key) = event {
|
||||
match key {
|
||||
Key::Enter => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::Show),
|
||||
}),
|
||||
Key::Char('e') => Some(Message::Exit {
|
||||
operation: Some(RequestedIssueOperation::Edit),
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -49,6 +49,12 @@ pub struct BrowserProps<'a> {
|
||||
search: String,
|
||||
}
|
||||
|
||||
impl<'a> BrowserProps<'a> {
|
||||
pub fn show_search(&self) -> bool {
|
||||
self.show_search
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&State> for BrowserProps<'_> {
|
||||
fn from(state: &State) -> Self {
|
||||
use radicle::issue::State;
|
||||
|
||||
Reference in New Issue
Block a user