Skip to content

Commit

Permalink
feat: exclude pending state in broadcast update (toeverything/OctoBas…
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Oct 17, 2023
1 parent 9128f57 commit c501820
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions y-octo/src/doc/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ impl Doc {
}
}

store.diff_state_vector(&before_state)
store.diff_state_vector(&before_state, false)
}

pub fn keys(&self) -> Vec<String> {
Expand Down Expand Up @@ -356,7 +356,7 @@ impl Doc {
}

pub fn encode_state_as_update(&self, sv: &StateVector) -> JwstCodecResult<Update> {
self.store.read().unwrap().diff_state_vector(sv)
self.store.read().unwrap().diff_state_vector(sv, true)
}

pub fn get_state_vector(&self) -> StateVector {
Expand Down
2 changes: 1 addition & 1 deletion y-octo/src/doc/publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl DocPublisher {
);

history.resolve_with_store(&store);
let (binary, history) = match store.diff_state_vector(&last_update) {
let (binary, history) = match store.diff_state_vector(&last_update, false) {
Ok(update) => {
drop(store);

Expand Down
8 changes: 5 additions & 3 deletions y-octo/src/doc/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ impl DocStore {
diff
}

pub fn diff_state_vector(&self, sv: &StateVector) -> JwstCodecResult<Update> {
pub fn diff_state_vector(&self, sv: &StateVector, with_pending: bool) -> JwstCodecResult<Update> {
let update_structs = Self::diff_structs(&self.items, sv)?;

let mut update = Update {
Expand All @@ -737,8 +737,10 @@ impl DocStore {
..Update::default()
};

if let Some(pending) = &self.pending {
Update::merge_into(&mut update, [pending.clone()])
if with_pending {
if let Some(pending) = &self.pending {
Update::merge_into(&mut update, [pending.clone()])
}
}

Ok(update)
Expand Down

0 comments on commit c501820

Please sign in to comment.