use tokio::sync::mpsc; use yazi_macro::{emit, relay}; use yazi_shared::{id::Id, url::UrlBuf}; use yazi_shim::SStr; pub struct AppProxy; impl AppProxy { pub async fn stop() { let (tx, mut rx) = mpsc::unbounded_channel(); emit!(Call(relay!(app:stop).with_replier(tx))); rx.recv().await; } pub async fn resume() { let (tx, mut rx) = mpsc::unbounded_channel(); emit!(Call(relay!(app:resume).with_replier(tx))); rx.recv().await; } } // --- Tasks pub struct TasksProxy; impl TasksProxy { pub fn update_succeed(id: Id, urls: I, track: bool) where I: IntoIterator, I::Item: Into, { emit!(Call( relay!(tasks:update_succeed, [id]) .with_list("urls", urls.into_iter().map(Into::into)) .with("track", track) )); } } // --- Notify pub struct NotifyProxy; impl NotifyProxy { pub fn push_warn(title: impl Into, content: impl Into) { emit!(Call( relay!(notify:push, [content.into(), title.into()]) .with("level", SStr::Borrowed("warn")) .with("timeout", 5f64) )); } pub fn push_error(title: impl Into, content: impl Into) { emit!(Call( relay!(notify:push, [content.into(), title.into()]) .with("level", SStr::Borrowed("error")) .with("timeout", 10f64) )); } }