From faab5ff083ea3a64a16331d6940174c0dfbce50a Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 24 Jun 2024 10:43:10 -0600 Subject: [PATCH] don't send empty patches --- json-patch | 2 +- patch-db/src/patch.rs | 4 ++++ patch-db/src/subscriber.rs | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/json-patch b/json-patch index 2065db4..4f762cf 160000 --- a/json-patch +++ b/json-patch @@ -1 +1 @@ -Subproject commit 2065db49ff1a7123cb08fd61c2b98d59e64a54da +Subproject commit 4f762cf7bc62fd84673314a1d2b0e93f4f4ca6a3 diff --git a/patch-db/src/patch.rs b/patch-db/src/patch.rs index bfaef46..4d764fb 100644 --- a/patch-db/src/patch.rs +++ b/patch-db/src/patch.rs @@ -211,6 +211,10 @@ impl DiffPatch { } keys } + + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } } impl Default for DiffPatch { fn default() -> Self { diff --git a/patch-db/src/subscriber.rs b/patch-db/src/subscriber.rs index c30d802..f9aa9c2 100644 --- a/patch-db/src/subscriber.rs +++ b/patch-db/src/subscriber.rs @@ -7,7 +7,11 @@ use crate::Revision; struct ScopedSender(JsonPointer, mpsc::UnboundedSender); impl ScopedSender { fn send(&self, revision: &Revision) -> Result<(), mpsc::error::SendError> { - self.1.send(revision.for_path(&self.0)) + let scoped = revision.for_path(&self.0); + if scoped.patch.is_empty() { + return Ok(()); + } + self.1.send(scoped) } }