Skip to content

Commit 56a4e87

Browse files
authored
fix: interoperability between number, integer, and id (#2883)
1 parent a076ff8 commit 56a4e87

File tree

12 files changed

+27
-46
lines changed

12 files changed

+27
-46
lines changed

yazi-core/src/notify/commands/push.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use std::time::Instant;
1+
use std::time::{Duration, Instant};
22

3-
use yazi_macro::emit;
4-
use yazi_shared::event::Cmd;
3+
use yazi_proxy::AppProxy;
54

65
use crate::notify::{Message, Notify};
76

@@ -14,7 +13,7 @@ impl Notify {
1413

1514
if self.messages.iter().all(|m| m != &msg) {
1615
self.messages.push(msg);
17-
emit!(Call(Cmd::args("app:update_notify", [0])));
16+
AppProxy::update_notify(Duration::ZERO);
1817
}
1918
}
2019
}

yazi-core/src/notify/commands/tick.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::time::Duration;
22

33
use ratatui::layout::Rect;
4-
use yazi_macro::emit;
4+
use yazi_proxy::AppProxy;
55
use yazi_shared::event::{Cmd, CmdCow, Data};
66

77
use crate::notify::Notify;
@@ -69,7 +69,7 @@ impl Notify {
6969

7070
self.tick_handle = Some(tokio::spawn(async move {
7171
tokio::time::sleep(interval).await;
72-
emit!(Call(Cmd::args("app:update_notify", [interval.as_secs_f64()])));
72+
AppProxy::update_notify(interval);
7373
}));
7474
}
7575
}

yazi-proxy/src/app.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ use crate::options::{NotifyLevel, NotifyOpt, PluginOpt};
99
pub struct AppProxy;
1010

1111
impl AppProxy {
12-
#[inline]
1312
pub async fn stop() {
1413
let (tx, rx) = oneshot::channel::<()>();
1514
emit!(Call(Cmd::new("app:stop").with_any("tx", tx)));
1615
rx.await.ok();
1716
}
1817

19-
#[inline]
2018
pub fn resume() {
2119
emit!(Call(Cmd::new("app:resume")));
2220
}
2321

24-
#[inline]
2522
pub fn notify(opt: NotifyOpt) {
2623
emit!(Call(Cmd::new("app:notify").with_any("option", opt)));
2724
}
2825

29-
#[inline]
26+
pub fn update_notify(dur: Duration) {
27+
emit!(Call(Cmd::args("app:update_notify", [dur.as_secs_f64()])));
28+
}
29+
3030
pub fn notify_warn(title: &str, content: impl ToString) {
3131
Self::notify(NotifyOpt {
3232
title: title.to_owned(),
@@ -36,7 +36,6 @@ impl AppProxy {
3636
});
3737
}
3838

39-
#[inline]
4039
pub fn notify_error(title: &str, content: impl ToString) {
4140
Self::notify(NotifyOpt {
4241
title: title.to_owned(),
@@ -46,12 +45,10 @@ impl AppProxy {
4645
});
4746
}
4847

49-
#[inline]
5048
pub fn plugin(opt: PluginOpt) {
5149
emit!(Call(Cmd::new("app:plugin").with_any("opt", opt)));
5250
}
5351

54-
#[inline]
5552
pub fn plugin_do(opt: PluginOpt) {
5653
emit!(Call(Cmd::new("app:plugin_do").with_any("opt", opt)));
5754
}

yazi-proxy/src/cmp.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ use yazi_shared::{Id, event::Cmd};
44
pub struct CmpProxy;
55

66
impl CmpProxy {
7-
#[inline]
87
pub fn close() {
98
emit!(Call(Cmd::new("cmp:close")));
109
}
1110

12-
#[inline]
1311
pub fn trigger(word: &str, ticket: Id) {
1412
emit!(Call(Cmd::args("cmp:trigger", [word]).with("ticket", ticket)));
1513
}

yazi-proxy/src/confirm.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ use yazi_shared::event::Cmd;
66
pub struct ConfirmProxy;
77

88
impl ConfirmProxy {
9-
#[inline]
109
pub async fn show(cfg: ConfirmCfg) -> bool { Self::show_rx(cfg).await.unwrap_or(false) }
1110

12-
#[inline]
1311
pub fn show_rx(cfg: ConfirmCfg) -> oneshot::Receiver<bool> {
1412
let (tx, rx) = oneshot::channel();
1513
emit!(Call(Cmd::new("confirm:show").with_any("tx", tx).with_any("cfg", cfg)));

yazi-proxy/src/input.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ use crate::options::CmpItem;
88
pub struct InputProxy;
99

1010
impl InputProxy {
11-
#[inline]
1211
pub fn show(cfg: InputCfg) -> mpsc::UnboundedReceiver<Result<String, InputError>> {
1312
let (tx, rx) = mpsc::unbounded_channel();
1413
emit!(Call(Cmd::new("input:show").with_any("tx", tx).with_any("cfg", cfg)));
1514
rx
1615
}
1716

18-
#[inline]
1917
pub fn complete(item: &CmpItem, ticket: Id) {
2018
emit!(Call(Cmd::new("input:complete").with_any("item", item.clone()).with("ticket", ticket)));
2119
}

yazi-proxy/src/mgr.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,40 @@ use crate::options::OpenDoOpt;
66
pub struct MgrProxy;
77

88
impl MgrProxy {
9-
#[inline]
109
pub fn spot(skip: Option<usize>) {
1110
emit!(Call(Cmd::new("mgr:spot").with_opt("skip", skip)));
1211
}
1312

14-
#[inline]
1513
pub fn peek(force: bool) {
1614
emit!(Call(Cmd::new("mgr:peek").with("force", force)));
1715
}
1816

19-
#[inline]
2017
pub fn watch() {
2118
emit!(Call(Cmd::new("mgr:watch")));
2219
}
2320

24-
#[inline]
2521
pub fn refresh() {
2622
emit!(Call(Cmd::new("mgr:refresh")));
2723
}
2824

29-
#[inline]
3025
pub fn open_do(opt: OpenDoOpt) {
3126
emit!(Call(Cmd::new("mgr:open_do").with_any("option", opt)));
3227
}
3328

34-
#[inline]
3529
pub fn remove_do(targets: Vec<Url>, permanently: bool) {
3630
emit!(Call(
3731
Cmd::new("mgr:remove_do").with("permanently", permanently).with_any("targets", targets)
3832
));
3933
}
4034

41-
#[inline]
4235
pub fn update_tasks(url: &Url) {
4336
emit!(Call(Cmd::new("mgr:update_tasks").with_any("urls", vec![url.clone()])));
4437
}
4538

46-
#[inline]
4739
pub fn update_paged() {
4840
emit!(Call(Cmd::new("mgr:update_paged")));
4941
}
5042

51-
#[inline]
5243
pub fn update_paged_by(page: usize, only_if: &Url) {
5344
emit!(Call(Cmd::args("mgr:update_paged", [page]).with_any("only-if", only_if.clone())));
5445
}

yazi-proxy/src/options/notify.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ pub enum NotifyLevel {
5252
}
5353

5454
impl NotifyLevel {
55-
#[inline]
5655
pub fn icon(self) -> &'static str {
5756
match self {
5857
Self::Info => &THEME.notify.icon_info,
@@ -61,7 +60,6 @@ impl NotifyLevel {
6160
}
6261
}
6362

64-
#[inline]
6563
pub fn style(self) -> &'static Style {
6664
match self {
6765
Self::Info => &THEME.notify.title_info,

yazi-proxy/src/pick.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use yazi_shared::event::Cmd;
66
pub struct PickProxy;
77

88
impl PickProxy {
9-
#[inline]
109
pub async fn show(cfg: PickCfg) -> anyhow::Result<usize> {
1110
let (tx, rx) = oneshot::channel();
1211
emit!(Call(Cmd::new("pick:show").with_any("tx", tx).with_any("cfg", cfg)));

yazi-proxy/src/tab.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@ use crate::options::SearchOpt;
88
pub struct TabProxy;
99

1010
impl TabProxy {
11-
#[inline]
1211
pub fn cd(target: &Url) {
1312
emit!(Call(Cmd::args("mgr:cd", [target])));
1413
}
1514

16-
#[inline]
1715
pub fn reveal(target: &Url) {
1816
emit!(Call(Cmd::args("mgr:reveal", [target]).with("no-dummy", true)));
1917
}
2018

21-
#[inline]
2219
pub fn arrow(step: impl Into<Cow<'static, str>>) {
2320
emit!(Call(Cmd::args("mgr:arrow", [step.into()])));
2421
}
2522

26-
#[inline]
2723
pub fn search_do(opt: SearchOpt) {
2824
emit!(Call(
2925
// TODO: use second positional argument instead of `args` parameter

0 commit comments

Comments
 (0)