diff --git a/yazi-core/src/confirm/commands/close.rs b/yazi-core/src/confirm/commands/close.rs index 542ec4d9..665b08ac 100644 --- a/yazi-core/src/confirm/commands/close.rs +++ b/yazi-core/src/confirm/commands/close.rs @@ -1,4 +1,3 @@ -use anyhow::anyhow; use yazi_shared::{event::Cmd, render}; use crate::confirm::Confirm; @@ -18,7 +17,7 @@ impl Confirm { pub fn close(&mut self, opt: impl Into) { let opt = opt.into() as Opt; if let Some(cb) = self.callback.take() { - _ = cb.send(if opt.submit { Ok(true) } else { Err(anyhow!("canceled")) }); + _ = cb.send(opt.submit); } self.visible = false; diff --git a/yazi-core/src/confirm/commands/show.rs b/yazi-core/src/confirm/commands/show.rs index 36dcb036..7f1f5faa 100644 --- a/yazi-core/src/confirm/commands/show.rs +++ b/yazi-core/src/confirm/commands/show.rs @@ -6,7 +6,7 @@ use crate::confirm::Confirm; pub struct Opt { cfg: ConfirmCfg, - tx: oneshot::Sender>, + tx: oneshot::Sender, } impl TryFrom for Opt { diff --git a/yazi-core/src/confirm/confirm.rs b/yazi-core/src/confirm/confirm.rs index 43b1774b..35f67e62 100644 --- a/yazi-core/src/confirm/confirm.rs +++ b/yazi-core/src/confirm/confirm.rs @@ -1,4 +1,3 @@ -use anyhow::Result; use tokio::sync::oneshot::Sender; use yazi_config::popup::Position; @@ -11,6 +10,6 @@ pub struct Confirm { pub offset: usize, pub position: Position, - pub(super) callback: Option>>, + pub(super) callback: Option>, pub visible: bool, } diff --git a/yazi-proxy/src/confirm.rs b/yazi-proxy/src/confirm.rs index eaf2925e..3605cea0 100644 --- a/yazi-proxy/src/confirm.rs +++ b/yazi-proxy/src/confirm.rs @@ -6,9 +6,9 @@ pub struct ConfirmProxy; impl ConfirmProxy { #[inline] - pub async fn show(cfg: ConfirmCfg) -> anyhow::Result { + pub async fn show(cfg: ConfirmCfg) -> bool { let (tx, rx) = oneshot::channel(); emit!(Call(Cmd::new("show").with_any("tx", tx).with_any("cfg", cfg), Layer::Confirm)); - rx.await? + rx.await.unwrap_or(false) } }