This commit is contained in:
sxyazi 2024-04-25 17:43:40 +08:00
parent 65003337f9
commit 029375c77f
No known key found for this signature in database
2 changed files with 13 additions and 13 deletions

View file

@ -21,7 +21,7 @@ impl<'a> BodyBulk<'a> {
impl BodyBulk<'static> {
#[inline]
pub fn dummy(tab: usize, changes: &HashMap<Url, Url>) -> Body<'static> {
pub fn owned(tab: usize, changes: &HashMap<Url, Url>) -> Body<'static> {
Self { tab, changes: Cow::Owned(changes.clone()) }.into()
}
}

View file

@ -118,18 +118,6 @@ impl Pubsub {
}
}
pub fn pub_from_bulk(tab: usize, changes: &HashMap<Url, Url>) {
if LOCAL.read().contains_key("bulk") {
Self::pub_(BodyBulk::dummy(tab, changes));
}
if PEERS.read().values().any(|p| p.able("bulk")) {
Client::push(BodyBulk::borrowed(tab, changes));
}
if BOOT.local_events.contains("bulk") {
BodyBulk::borrowed(tab, changes).with_receiver(*ID).flush();
}
}
pub fn pub_from_rename(tab: usize, from: &Url, to: &Url) {
if LOCAL.read().contains_key("rename") {
Self::pub_(BodyRename::dummy(tab, from, to));
@ -142,6 +130,18 @@ impl Pubsub {
}
}
pub fn pub_from_bulk(tab: usize, changes: &HashMap<Url, Url>) {
if LOCAL.read().contains_key("bulk") {
Self::pub_(BodyBulk::owned(tab, changes));
}
if PEERS.read().values().any(|p| p.able("bulk")) {
Client::push(BodyBulk::borrowed(tab, changes));
}
if BOOT.local_events.contains("bulk") {
BodyBulk::borrowed(tab, changes).with_receiver(*ID).flush();
}
}
pub fn pub_from_yank(cut: bool, urls: &HashSet<Url>) {
if LOCAL.read().contains_key("yank") {
Self::pub_(BodyYank::dummy());