Skip to content

Commit d015cfc

Browse files
committed
..
1 parent 408182a commit d015cfc

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

yazi-core/src/tab/commands/cd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::{mem, time::Duration};
33
use tokio::{fs, pin};
44
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
55
use yazi_config::popup::InputCfg;
6+
use yazi_dds::Pubsub;
67
use yazi_proxy::{CompletionProxy, InputProxy, ManagerProxy, TabProxy};
78
use yazi_shared::{event::Cmd, fs::{expand_path, Url}, render, Debounce, InputError};
89

@@ -64,6 +65,7 @@ impl Tab {
6465
self.backstack.push(opt.target.clone());
6566
}
6667

68+
Pubsub::pub_from_cd(&self.current.cwd);
6769
ManagerProxy::refresh();
6870
render!();
6971
}

yazi-dds/src/client.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,15 @@ impl Client {
8181
}
8282

8383
fn handle_hey(s: String) {
84-
if let Ok(Body::Hey(hey)) = Payload::from_str(&s).map(|p| p.body) {
84+
if let Ok(Body::Hey(mut hey)) = Payload::from_str(&s).map(|p| p.body) {
85+
hey.peers.retain(|&id, _| id != *ID);
8586
*PEERS.write() = hey.peers;
8687
}
8788
}
8889
}
8990

9091
impl Peer {
92+
#[inline]
9193
pub(super) fn new(abilities: &HashSet<String>) -> Self { Self { abilities: abilities.clone() } }
9294

9395
#[inline]

yazi-dds/src/pubsub.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::collections::HashMap;
22

33
use mlua::Function;
44
use parking_lot::RwLock;
5-
use yazi_shared::{emit, event::Cmd, timestamp_ms, Layer, RoCell};
5+
use yazi_shared::{emit, event::Cmd, fs::Url, timestamp_ms, Layer, RoCell};
66

7-
use crate::{Body, BodyHi, Payload, ID, PEERS, QUEUE};
7+
use crate::{Body, BodyCd, BodyHi, Payload, ID, PEERS, QUEUE};
88

99
pub static LOCAL: RoCell<RwLock<HashMap<String, HashMap<String, Function<'static>>>>> =
1010
RoCell::new();
@@ -97,4 +97,17 @@ impl Pubsub {
9797
});
9898
true
9999
}
100+
101+
pub fn pub_from_cd(url: &Url) {
102+
if LOCAL.read().contains_key("cd") {
103+
Self::pub_with(Body::Cd(BodyCd { url: url.clone() }));
104+
}
105+
if PEERS.read().values().any(|p| p.able("cd")) {
106+
_ = QUEUE.send(Payload {
107+
receiver: 0,
108+
timestamp: timestamp_ms(),
109+
body: Body::Cd(BodyCd { url: url.clone() }),
110+
});
111+
}
112+
}
100113
}

0 commit comments

Comments
 (0)